ubuntu10.10下memcache类delete失败的原因

 ubuntu10.10 desktop,安装了memcached,后来写了一个php文件来测试memcache:
connect('127.0.0.1',11211);
$mem->delete('key');
?>

结果在delete的时候老是报错:

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  [noreply]   
 (0) in /home/coinsight/clear.php on line 4  
coinsight@insight-ubuntu:~$


查找了半天原因发现在delete后面加个参数就可以了,而且这个参数必须是0,其它的值同样报错:

connect('127.0.0.1',11211);
$mem->delete('key',0);
?>


后来百度+GG找,原因如下:

nibblebot at gmail dot com 09-Jul-2010 03:58 
the Memcache::delete(key) function is broken on several combinations of memcached+pecl-memcache combinations. 

pecl-memcache 2.2.5 + memcached 1.4.2 - Memcache::delete(key) WORKS

pecl-memcache 2.2.5 + memcached 1.4.3 - Memcache::delete(key) DOES NOT WORK

pecl-memcache 2.2.5 + memcached 1.4.4 - Memcache::delete(key) WORKS

pecl-memcache 2.2.5 + memcached 1.4.5 - Memcache::delete(key) WORKS

pecl-memcache 3.0.4 + memcached 1.4.2 - Memcache::delete(key) WORKS

pecl-memcache 3.0.4 + memcached 1.4.3 - Memcache::delete(key) DOES NOT WORK

pecl-memcache 3.0.4 + memcached 1.4.4 - Memcache::delete(key) DOES NOT WORK

pecl-memcache 3.0.4 + memcached 1.4.5 - Memcache::delete(key) DOES NOT WORK


 解决方案:(1)手动安装对应的版本 (2)在delete函数里面多加一个参数0。

你可能感兴趣的:(Code)