escapework/cache

缓存控制库

0.1.2 2013-04-04 20:33 UTC

This package is auto-updated.

Last update: 2024-08-29 03:35:22 UTC


README

建设中。

示例

use EscapeWork\Cache\Facade as Cache;

# setting 
Cache::set('key', 'value', 'namespace'); # namespace é opcional 

# getting
# if the value don't exists in cache, the closure is called
Cache::get('key', function() {
    return 'your function to get data';
}, 'namespace');

# deleting 
Cache::delete('key');

# flush namespace 
Cache::flushNamespace('namespace');

# flush all cache 
Cache::flush();

可用的缓存类型

  • Memcached
  • APC
  • 文件
  • 数组(用于单元测试)

配置

use EscapeWork\Cache\Facade as Cache;

Cache::driver(array(
    'driver' => 'memcached', 
    'memcached' => array(
        array('host' => 'your-host', 'port' => 11211) # server settings 
    ), 
));

Cache::driver(array(
    'driver' => 'file', 
    'path'   => '/path/to/your/cache/dir/', 
));

安装

安装可通过 Composer 进行。支持 PSR-0 自动加载。

{
    "require": {
        "escapework/cache": "0.1.*"
    }
}