Use Redis as your cache system
Redis is a great cache system, it store the cache in ram and send it to the hard drive once in a while, so you dont lose when the pc shut down
Download and extract it on your extensions folder . The main file must be located in application.extensions.redis.CRedisCache
To setup :
define in the application's configuration array ( by default configs/main.php)
'components'=>array( 'cache'=>array( 'class'=>'ext.redis.CRedisCache', //if you dont set up the servers options it will use the default one //"host=>'127.0.0.1',port=>6379" 'servers'=>array( array( 'host'=>'server1', 'port'=>6379, ), //if you use 2 servers array( 'host'=>'server2', 'port'=>6379, ), ), ), ),
Be sure that its under components
then you can use any redis function by calling it normally Yii way, like :
//yii's default functions Yii::app()->cache->get($name); Yii::app()->cache->set($name,$value,$time); //redis specific functions Yii::app()->cache->{$function}($arg1,$arg2,$arg3); //example of selecting a db Yii::app()->getCache()->select(2);
It uses Predis as redis php client
Thumbs up
Total 6 comments
Please, follow me on the forum to go on with replying.
I've done that on 2012/06/03. no worries the Predis is included in the archive attached in forum
it's here is you want it https://github.com/nrk/predis/tree/v0.7.2
Sorry, but at
https://github.com/nrk/predis
version is 0.8 ! What's 7.2?
Also, YiiRedis require a php extension and we CANNOT use it. I need a php pure library
@realtebo it seems it's dead, I've upgraded the Predis to 7.2, and fixed it
it seems fine for my needs, but others are reporting that mget watch does not work see the yii forum link above
you might consider this alternative https://github.com/phpnode/YiiRedis
We'd like to start using your extension for a large application.
It looks like a very good start point, could you tell me if this extensions is 'live', is maintened and keep updated ?
here is an updated version
http://www.yiiframework.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=2926
you can discuss it in the forum
http://www.yiiframework.com/forum/index.php?/topic/13348-redis-cache/
Leave a comment
Please login to leave your comment.