Yii Framework Forum: Redis Cache - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Redis Cache Use Redis as your cache system Rate Topic: -----

#21 User is offline   Saniek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 26-November 12

Posted 26 November 2012 - 05:46 AM

Hi.
Mget operation does not work.
Doing so:

$cache=Yii::app()->cache;
$tmp=array('test1','test2');
$mas=$cache->get($tmp);
print_r($mas);
Array([test1]=>,[test2]=>)

Gives empty answers
But separately is getting all right.
0

#22 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 700
  • Joined: 03-October 12
  • Location:Ferrara

Posted 30 May 2013 - 03:20 AM

just a performance test (using servers in localhost)

APC
========
10000 single integer write : 0.028426885604858 seconds

REDIS
========
10000 single integer write : 6.9566950798035 seconds

MEMCACHE
========
10000 single integer write : 3.1675958633423 seconds
Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

#23 User is offline   muayyad alsadi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-April 11

Posted 30 May 2013 - 03:26 AM

is this using my updated version or the original one ?

and can we compare to different redis implementations like this one

https://github.com/phpnode/YiiRedis

would you post the script you use to benchmark here https://gist.github.com/
0

#24 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 700
  • Joined: 03-October 12
  • Location:Ferrara

Posted 30 May 2013 - 06:29 AM

I'm using your version, without any modifications.

The script is a simple sequence of for using 'get' or 'set'.
Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

#25 User is offline   muayyad alsadi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-April 11

Posted 30 May 2013 - 07:12 AM

this my benchmark code
https://gist.github....c3c5dc58a1a033e

10,000 set of simple key and simple string value (I've also tried integer value of 10)

./protected/cmdrun cache benchmark
YiiRedis delta 1.1029698848724
Predis delta 1.7682290077209
[alsadi@localhost muayyad-appii]$ 

0

#26 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 700
  • Joined: 03-October 12
  • Location:Ferrara

Posted 30 May 2013 - 11:47 AM

Argh !! I'll try to use ->getClient to directly access redis... thanks for this benchmark
Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

#27 User is offline   muayyad alsadi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-April 11

Posted 30 May 2013 - 11:59 AM

getClient is for the YiiRedis not PRedis
0

#28 User is offline   Konstantinos Filios 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 28-February 13
  • Location:Athens, Greece

Posted 10 June 2013 - 09:41 AM

Hi Gustavo and Muayyad,

thanks for the great extension. I'm only having some issues with addValue(), which I'm using to implement exclusive locks for an application of mine. It looks like there's some typo in the method, namely the $time variable which is not initialized anywhere. I will fix it in my copy, but I guess it would be better if you fixed it in your distribution as well.

	protected function addValue($key,$value,$expire)
	{
		if($expire>0){
        	if($this->_cache->setnx($key,$time,$value))
            	return $this->_cache->expire($key,$time);
        	return false;
		}else
			return $this->_cache->setnx($key,$value);
	}

0

#29 User is offline   Nguyen Tuan Quyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 15-March 12

Posted 13 June 2013 - 12:15 PM

Hi all,

I'm using CRedisCache with redis server 2.6.13 and getting stuck with mget function... It seems to me that the mget function of CCache.php does not work properly. Below is what I did
- I used the
set
function to save to cache my objects under array format like this:
Yii::app()->cache->{'set'}($key, $value); // $key is an integer, $value is an array


- After that i used
mget
on passing a list of keys to get the corresponding objects, but it return an error like below:

PHP notice

Undefined offset: 0

/Users/NguyenTuanQuyen/Sites/cms/core/cms/extensions/redis/Predis/Network/StreamConnection.php(280)

268      */
269     public function writeCommand(ICommand $command)
270     {
271         $commandId = $command->getId();
272         $arguments = $command->getArguments();
273 
274         $cmdlen = strlen($commandId);
275         $reqlen = count($arguments) + 1;
276 
277         $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n";
278 
279         for ($i = 0; $i < $reqlen - 1; $i++) {
[b]280             $argument = $arguments[$i];[/b]
281             $arglen = strlen($argument);
282             $buffer .= "\${$arglen}\r\n{$argument}\r\n";
283         }
292     {
....


- I also try
multi & exec
with
get
but it doesn't work either. There's an error like:

unserialize(): Error at offset 0 of 6 bytes


Stack Trace

#0	
+  /Users/NguyenTuanQuyen/Sites/cms/core/yii/framework/caching/CCache.php(108): unserialize("QUEUED")
#1	
–  /Users/NguyenTuanQuyen/Sites/thethao/common/components/RedisCacheHelper.php(27): CCache->get("63")
22     const MAX_ARTICLE_PER_TERM = 500;
23 
24     const PREFIX_HASH_KEY = 'hv_';
25 
26     public static function get($key) {
27         return Yii::app()->cache->{'get'}($key);
28     }
29 


Thanks a million for helping me!
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users