#1939 when using ->set() with an expiration, values come back wrong when -> get
Submitted: 2004-07-21 18:04 UTC
From: jmat at shutdown dot net Assigned:
Status: Bogus Package:
PHP Version: 5CVS-2004-07-21 (dev) OS: Mac OSX
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-21 18:04 UTC] jmat at shutdown dot net
Description: ------------ when setting a memcache value, and you specify an expiration time, the module appears to "double" serialize the value, so when you retrieve it later, it's still in a serialized string format. Reproduce code: --------------- <?php $memc = memcache_pconnect("localhost",11211); $values = array(1,2,3,4,5,6,7,8,9); echo "Values: \n"; print_r($values); echo "\n------------------------------\n"; $memc->set("myVals",$values,100); $newValues = $memc->get("myVals"); echo"New Values:\n"; print_r($newValues); echo "\n"; ?> Expected result: ---------------- Values: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 ) ------------------------------ New Values: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 ) Actual result: -------------- Values: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 ) ------------------------------ New Values: a:9:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;i:6;i:7;i:7;i:8;i:8;i:9;}

Comments

 [2004-07-21 18:05 UTC] jmat at shutdown dot net
this is using php 5.0 and memcache module 1.20
 [2004-07-22 06:45 UTC] tony2001 at php dot net
Expire time is the 4th parameter of set() function, check the docs: http://php.net/memcache_set Don't use any values of flags parameter different from false and MEMCACHE_COMPRESSED. The function should check it, I'll probably change this in the future.