maximebf / cachecache
该包已被废弃,不再维护。未建议替代包。
PHP5.3 缓存库
1.0.2
2013-08-12 09:30 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-05-25 11:36:30 UTC
README
PHP 5.3+ 缓存框架
特性
- 使用多种方法轻松检索和存储键值对
- 缓存函数调用
- 可用的对象包装器,用于缓存方法调用
- 类似 Predis 的管道(见下文)
- 命名空间
- 不同的 TTL 以避免所有缓存同时过期
- 支持多个后端(apc、文件、memcache(d)、内存、redis、session)
- Monolog 支持
- 非常完善的文档
CacheCache 通过 Cache 对象暴露特性,该对象本身使用后端存储数据。可以使用 CacheManager 管理多个 Cache 对象实例。
完整文档请见 http://maximebf.github.com/CacheCache/
示例
$cache = new CacheCache\Cache(new CacheCache\Backends\Memory());
if (($foo = $cache->get('foo')) === null) {
$foo = 'bar';
$cache->set('foo', $foo);
}
if (!$cache->start('foo')) {
echo "bar\n";
$cache->end();
}
$cache->call('sleep', array(2));
$cache->call('sleep', array(2)); // won't sleep!
$r = $cache->pipeline(function($pipe) {
$pipe->set('foo', 'bar');
$pipe->set('bar', 'foo');
$pipe->get('foo');
$pipe->set('foo', 'foobar');
$pipe->get('foo');
});
更多示例请见 examples/