memcache delete 数据无法删除
kevin.Zhu 发布于:2013-1-16 12:12 分类:Memcache 有 11 人浏览,获得评论 0 条
http://blog.csdn.net/uixor_/article/details/6758565
ubuntu10.10 desktop,安装了memcached,后来写了一个php文件来测试memcache:
[php] view plaincopyprint?
01.<?php
02.$mem = new Memcache;
03.$mem->connect('127.0.0.1',11211);
04.$mem->delete('key');
05.?>
<?php
$mem = new Memcache;
$mem->connect('127.0.0.1',11211);
$mem->delete('key');
?>
结果在delete的时候老是报错:
[plain] view plaincopyprint?
01.coinsight@insight-ubuntu:~$ php clear.php
02.PHP Notice: MemcachePool::delete(): Server 127.0.0.1 (tcp 11211, udp 0)
03.failed with: CLIENT_ERROR bad command line format. Usage: delete <key> [noreply]
04. (0) in /home/coinsight/clear.php on line 4
05.coinsight@insight-ubuntu:~$
coinsight@insight-ubuntu:~$ php clear.php
PHP Notice: MemcachePool::delete(): Server 127.0.0.1 (tcp 11211, udp 0)
failed with: CLIENT_ERROR bad command line format. Usage: delete <key> [noreply]
(0) in /home/coinsight/clear.php on line 4
coinsight@insight-ubuntu:~$
查找了半天原因发现在delete后面加个参数就可以了,而且这个参数必须是0,其它的值同样报错:
[php] view plaincopyprint?
01.<?php
02.$mem = new Memcache;
03.$mem->connect('127.0.0.1',11211);
04.$mem->delete('key',0);
05.?>