问题描述
Memcached应该正确安装.我正在使用php 5.4
使用此代码,我应该得到"99",但最终得到的是"bool(false)".
$m = new Memcached();
$m->addServer('localhost', 11211);
$m->set('int', 99);
var_dump($m->get('int'));
这是很久以前问过的,但在Google搜索中排名较高,因此,该答案可能会对寻找该问题答案的人有所帮助.
检查是否确实安装了Memcached
运行命令telnet 127.0.0.1 11211
,如果连接失败,则需要安装Memcached或检查防火墙是否允许端口11211连接.
对于Ubuntu,命令为sudo apt-get install memcached
Memcached should be installed correctly. I'm using php 5.4
With this code I should get '99' as a result but I end up with 'bool(false)'.
$m = new Memcached();
$m->addServer('localhost', 11211);
$m->set('int', 99);
var_dump($m->get('int'));
This has been asked long ago, yet ranks up at Google search so the answer might be helpful for someone looking for the answer to this question.
Check if Memcached is really installed
Run the command telnet 127.0.0.1 11211
and if the connection fails then you need to install Memcached or check if your Firewall allows the port 11211 connections.
For Ubuntu, the command is sudo apt-get install memcached
这篇关于memcached get函数始终返回'bool(false)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!