bkhrupa / kohana-rediscache
非常简单的 kohana3.3 版本 phpredis 缓存模块
1.2.0
2015-02-25 22:50 UTC
Requires
- php: >=5.3.3
- composer/installers: ~1.0
- kohana/cache: >=3.3
- kohana/core: >=3.3
This package is auto-updated.
Last update: 2024-09-24 01:15:48 UTC
README
非常简单的 kohana3.3 版本 phpredis 缓存模块 :) 需要 Kohana 缓存模块
Redis 客户端 - phpredis (https://github.com/nicolasff/phpredis)
原始模块 - (https://github.com/infarmer/phpredis-kohana3.3)
示例
启用模块 bootstrap.php
Kohana::modules(array(
...
'cache' => MODPATH.'cache',
'rediscache' => MODPATH.'rediscache',
...
));
配置。在 Kohana 缓存配置中添加 redis 驱动 config/cache.php
...
'redis' => array(
'driver' => 'redis',
'port' => 6379,
'host' => 'localhost',
'db_num' => 0,
'igbinary_serialize' => false,
'password' => '',
),
...
如果默认需要 redis 缓存驱动 bootstrap.php
// default cache driver
Cache::$default = 'redis';
用法
$redis_cache = Cache::instance('redis');
$redis_cache->set('test_cache', array('foo', 'bar'), 10);
$redis_cache->get('test_cache');