以下代码
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);
$data = json_encode(array(
'string1' => md5(time()),
'string2' => md5(time())
));
var_dump($memcached->set('foo', $data, 300));
工作得很好
# telnet 127.0.0.1 11211
# get foo
VALUE foo 0 91
{"string1":"884e036fd865cac1ef26b5f7a920c2c2","string2":"884e036fd865cac1ef26b5f7a920c2c2"}
但是当我添加第三行时
$data = json_encode(array(
'string1' => md5(time()),
'string2' => md5(time()),
'string3' => md5(time())
));
var_dump($memcached->set('foo', $data, 300));
它产生以下
# get foo
VALUE foo 16 63
x«V*.)ÊÌK7T²RJ322J11KL6M4I4OM¶°H57·4716I5Oµ0NSÒ*6"E±11krW&z
我猜 memcached 正在以某种方式压缩该值,但为什么它不在 get 时恢复它呢?
知道如何解决吗?