ci 集成redis

希望在CI中使用redis作为缓存驱动,发现官方github上已经有了,貌似要到3.0才正式发布,先用上吧,省事了
为了保持框架可升级操作如下


1、将systemlibrariesCacheCache.php复制为applicationlibrariesCacheCache.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放到applicationlibrariesCachedrivers下


3、测试

$this->load->driver('cache', array('adapter' => 'redis'));
if ( ! $foo = $this->cache->get('foo'))
{
     echo 'Saving to the cache!
';
     $foo = 'foobarbaz!';
     // Save into the cache for 5 minutes
     $this->cache->save('foo', $foo, 300);
}
echo $foo;
原文地址:https://www.cnblogs.com/pan123/p/4260453.html