now i'm working on a project with memcached in php, and now i have a problem
stuck me for some days
when i tried to save object into the memcached, the value stored in the
memcached didnt match the thing i put into
suppose now i want to save a object
class Test_Obj {
public $a = 1;
public $b = 2;
public $c = 3;
/*
*/
public function __sleep(){
print 'test';
return array('a', 'b');
}
/*
*/
public function __unset($name){
unset($this->$name);
}
}
$testObj = new Test_Obj();
$memcached = new Memcached();
$memcachedKey = 'test_obj';
$memcached->setOption(Mist_Memcached::OPT_SERIALIZER,Memcached::SERIALIZER_PHP);
$memcached->set($memcachedKey, $testObj, 10);
$data = $memcached->get($memcachedKey);
var_dump($data);
i think the output should be like:
testobject(Test_Obj)#252 (3) { ["a"]=> int(2) ["b"]=> int(2)}
but actually the result is different:
testobject(Test_Obj)#252 (3) { ["a"]=> int(2) ["b"]=> int(2) ["c"]=> int(3)
}
what i couldnt understand is, it does invoke the __sleep function, print the
'test' string, but the value stored in the memcached still have the 'c'
property.
and i tested for the second time.
i added some unset code like:
$testObj = new Test_Obj();
$memcached = new Memcached();
$memcachedKey = 'test_obj';
$memcached->setOption(Mist_Memcached::OPT_SERIALIZER,Memcached::SERIALIZER_PHP);
unset($testObj->c);
$memcached->set($memcachedKey, $testObj, 10);
$data = $memcached->get($memcachedKey);
var_dump($data);
the output is the same as above.
testobject(Test_Obj)#252 (3) { ["a"]=> int(2) ["b"]=> int(2) ["c"]=> int(3)
}
i cant understand why i unset the property 'c' but still get the the memcached
value with the property 'c'
is there anyone can help me? honestly thanks
Original issue reported on code.google.com by jameshu1...@gmail.com on 14 Oct 2010 at 9:56
Original issue reported on code.google.com by
jameshu1...@gmail.com
on 14 Oct 2010 at 9:56