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
Requirements ¶
- PHP 5.2.x
- Tested with Yii 1.1.5, should work with any 1.1.*
- A redis server running
Usage ¶
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);
Version ¶
- 0.2 Fixed a couple of bugs and rewrite of the code (25/02/11)
- 0.1 Release
Resources ¶
It uses Predis as redis php client
- [[Redis page]](http://code.google.com/p/redis/ "Redis page")
- [[Predis page]](https://github.com/nrk/predis "Predis page")
- Installing Redis on CentOs5
Thumbs up
suggested update to Predis 7.2
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/
is it updated and mantained ?
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 ?
yii redis
@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
PRedis 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
it was the latest
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
i'm moving to the forum
Please, follow me on the forum to go on with replying.
Hi Gustavo / muayyad alsadi
Hi,
This is a great extension .
I am using YIi User modules for user management . Is there any change in needed in user module when i use redis ?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.