Yii 1.1: yii-redis

Provides object oriented access to Redis in a familiar Yii Style

Provides object oriented access to Redis in a familiar Yii Style. When you add or remove items from redis entities (lists, sets, sorted sets, hashes), changes are pushed to the server immediately, this is useful when your application needs to make information available across multiple requests.


This package relies on the https://github.com/nicolasff/phpredis PHP extension, please make sure this is installed before continuing.


Please see the github project page for usage examples.


Total 10 comments

#17797 report it
romdoni at 2014/07/23 06:02am
getting error while check data that is exist or not

I'm getting error while try to check hash data is exists or not this is my code

$username = $hash->username;
if($username === false){
//create hash
$hash->username = "vasilis";
$username = $hash->username;
echo $username;

i've read the documentation of redis, for check hash is exist or not

redis> HSET myhash field1 "foo"
(integer) 1
redis> HEXISTS myhash field1
(integer) 1
redis> HEXISTS myhash field2
(integer) 0


#16895 report it
ldg at 2014/04/10 11:51am

Are there pros/cons to using YiiRedis instead of CRedisCache in 1.14? Does the PhpRedis extension YiiRedis uses make it more performant?

My application is still on 1.13 and is working fine, but I am trying to evaluate if I do update to 1.14 what other changes I might make. Thanks much.

#12562 report it
Bulki S Maslom at 2013/03/28 08:06pm
ARedisCache flush() is not working

WORKS if I modify ARedisCache flush():

public function flush() {
    return (bool) $this->getConnection()->getClient()->flushAll();
#9093 report it
gattu_marrudu at 2012/07/19 10:38am
To add redis password support

If you have a password-protected Redis server you can add the following property to ARedisConnection:

public $authString='';

And change getClient method from

    if ($this->_client === null) {
        $this->_client = new Redis;
        $this->_client->connect($this->hostname, $this->port);
    return $this->_client;


    if ($this->_client === null) {
        $this->_client = new Redis;
        $this->_client->connect($this->hostname, $this->port);
    return $this->_client;

It would be nice if you could add this to your release!

#7259 report it
ldg at 2012/03/07 12:12pm

Thanks much for the quick reply, my oversight, works a treat with Phpredis. I assume the flush issue wont' affect using it for Yii session management. I do wonder if using flushdb would be one way to get that to work -- obviously would assume that the db is used exclusively for cache.

#7199 report it
phpnode at 2012/03/03 03:05am

This extension depends on phpredis, it may partly work with predis but its not supported. Flushing the cache is not currently supported, I will look into it

#7197 report it
ldg at 2012/03/02 07:09pm
couple questions

This looks great but I have a couple questions about setting up the environment - I have Predis (0.7.1) running and it works fine - when I load your extension

In order to avoid a "Redis.php - No such file", I needed to change the client connection from:
$this->_client = new Redis;
$this->_client = new Predis\Client();

There are a couple other issues as well, like I needed to change your "delete" command to "del", and similarly I get "'flush' is not a registered Redis command" when trying to clear/flush the cache -- is that supposed to be flushdb or am I doing something wrong?

Also, Gustavo, is there any benefit to using this over your extension for Yii cache at this point?

Thanks much.

#6918 report it
Haensel at 2012/02/13 02:00pm

This will save a lot of work. Thanks!



#6288 report it
Peter JK at 2011/12/25 10:25am
something new

Wow... php redis its really something new for me. Thx and its really good for tuning all of my yii apps.. lets see how fast and how it works...

#6225 report it
Gustavo at 2011/12/20 07:05am
Well done!

I've been meaning to do something like this for a while, but never found the time !

Cheers, Gustavo

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet