无法与memcache服务器连接

时间:2017-11-01 09:08:07

标签: php web-services

我完全安装了memcache并且我创建了一个新实例,但我不明白我是否连接到正确的端口。它总是返回“无法连接”

这是我的代码:

$memcache = new Memcache;
$memcache->connect('localhost',11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

0 个答案:

没有答案