希望在CI中使用redis作为缓存驱动,发现官方github上已经有了:D,貌似要到3.0才正式发布,先用上吧,省事了
为了保持框架可升级操作如下,
1、将system\libraries\Cache\Cache.php复制为application\libraries\Cache\Cache.php
增加配置
protected $valid_drivers = array(
'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_redis'
);
2、将https://github.com/EllisLab/CodeIgniter/blob/develop/system/libraries/Cache/drivers/Cache_redis.php放到application\libraries\Cache\drivers下
3、测试:
在控制器中
class Data extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->driver('cache', array('adapter' => 'redis'));
}
public function test(){
//$this->cache->save('soho',"111", 300);
//$s = $this->cache->get('soho');
//var_dump($s);
}
}