memcached get函数始终返回'bool(false)' [英] memcached get function always returns 'bool(false)'

查看:144
本文介绍了memcached get函数始终返回'bool(false)'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

memcached settings

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)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆