当我尝试使用Memcached设置值时,为什么总是返回Memcached :: RES_NO_SERVERS?

时间:2012-08-14 16:06:56

标签: php memcached

$ sudo service memcached start
Starting memcached: memcached.

$ php-shell.sh 
PHP-Shell - Version 0.3.1, with readline() support
(c) 2006, Jan Kneschke <jan@kneschke.de>

>> use '?' to open the inline help 

>> $mc = new Memcached('start')
Memcached::__set_state(array(
))
>> $mc->set('x','y')
false
>> $mc->getResultCode()
20
>> Memcached::RES_NO_SERVERS
20

我已经启动了memcached,所以大概是服务器正在运行,不是吗?我是否需要做任何其他事情才能找到服务器?

1 个答案:

答案 0 :(得分:3)

您需要先连接到服务器...

http://www.php.net/manual/en/memcached.addserver.php

Memcached::addServer('localhost', 11211);