狠狠撸

狠狠撸Share a Scribd company logo
codeigniter cache driver : redis
CI 2.x + Redis codeigniter
整合 redis 的暫存功能
– wiki
「Redis是?一個開源、??支援網路、?基於記憶體、?鍵值
對儲存資料庫,使?用ANSI C編寫。?」
Ubuntu + Nginx + Redis libs
? 要先讓web server?支援redis,執?行底下的指令
$ apt-get install php5-redis
$ service php5-fpm restart
$ service nginx restart
Codeigniter vs Redis
? CI 2.x 沒有 Redis 的 Driver
? CI 3.x 有 Redis 的 Driver
整合?方式
?避免更新System時,把redis driver移除,所以建議放到
application下。?
1.將systemlibrariesCacheCache.php copy到
applicationlibrariesCacheCache.php
2.在 applicationcon?g中,建?立 redis.php的con?g檔
案
3.下載CI3.x 的 Cache_redis.php 存入 application
librariesCachedrivers
整合图?示
使?用?方式
$this->load->driver('cache');
if ($this->cache->is_supported('redis'))?
{
$this->cache->redis->save('cache_key', 'cache_value', 300);
echo $this->cache->redis->get('cache_key');
}
參考資料
? Wiki- Redis?
http://zh.wikipedia.org/wiki/Redis
? CI 2.x + Redis?
http://codeigniter.org.cn/forums/thread-17108-1-1.html
? CI 3.x 的 Cache_Redis.php?
https://github.com/bcit-ci/CodeIgniter/blob/develop/
system/libraries/Cache/drivers/Cache_redis.php?

More Related Content

CI2.x 加入連線 redis 的功能