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.
Requirements ¶
This package relies on the https://github.com/nicolasff/phpredis PHP extension, please make sure this is installed before continuing.
Usage ¶
Please see the github project page for usage examples.
Well done!
I've been meaning to do something like this for a while, but never found the time !
Cheers,
Gustavo
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...
Thanks!
This will save a lot of work. Thanks!
Greetings,
Hannes
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;
to:
$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.
@iglefan
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
Phpredis
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.
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;
to
if ($this->_client === null) { $this->_client = new Redis; $this->_client->connect($this->hostname, $this->port); $this->_client->auth($this->authString); } return $this->_client;
It would be nice if you could add this to your release!
ARedisCache flush() is not working
WORKS if I modify ARedisCache flush():
public function flush() { return (bool) $this->getConnection()->getClient()->flushAll(); }
CRedisCache
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.
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 redis>
Thanks,
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.