rediscache Use Redis as your cache system

  1. Requirements
  2. Usage
  3. Version
  4. Resources

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

forum / suport

It uses Predis as redis php client

Thumbs up

14 0
19 followers
5 235 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Caching
Developed by: Gustavo
Created on: Dec 20, 2010
Last updated: 6 years ago

Downloads

show all

Related Extensions