Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakePHP memcache逻辑不工作_Php_Cakephp_Windows 7_Memcached_Telnet - Fatal编程技术网

cakePHP memcache逻辑不工作

cakePHP memcache逻辑不工作,php,cakephp,windows-7,memcached,telnet,Php,Cakephp,Windows 7,Memcached,Telnet,我的问题是,我的cakePHP应用程序中的memcache逻辑在我的本地系统上不起作用,因为我在这里设置了它,从现有的队友设置中获取代码。我已经检查了Memcached服务是否在我的系统上运行,phpinfo()显示memcache部分已启用 但是,像这样的事情是行不通的- $this->Memcache->set($key,$value); CakePHP将其包装器用于Memcache,v。0.3 如果我像这样调试- echo "<pre>"; e

我的问题是,我的cakePHP应用程序中的memcache逻辑在我的本地系统上不起作用,因为我在这里设置了它,从现有的队友设置中获取代码。我已经检查了Memcached服务是否在我的系统上运行,phpinfo()显示memcache部分已启用

但是,像这样的事情是行不通的-

$this->Memcache->set($key,$value);
CakePHP将其包装器用于Memcache,v。0.3

如果我像这样调试-

echo "<pre>";
echo "checking";
error_reporting(-1); 
$this->Memcache->set($key,$countryNetworkWiseReportData,3600);
echo "finished";
exit;
return @$this->_Memcache_cluster_new->set($key, $var, 0, time()+$expires);
给-

telnet localhost:11211 (in case firewall issues prevent connection to 127.0.0.1)
也试过-

if(!$this->memcacheCommon())
{
    $this->log('Error in memcache', LOG_DEBUG);
    die('Error in memcache');
}

//like in others system, in my system too, it passes above condition

$memcachedata = $this->Memcache->get($key);
//does not return data in my system, because $this->Memcache->set($key,$data); never sets the data correctly.

if(got data from memcache)
{
    //Return that data
}
else
{
    //Get data from database
    $this->Memcache->set($key,$data); //does not the data in my setup - set() function returns false
}
但也犯了同样的错误

我还尝试了这个名为memcache.php的脚本。我把
$arr=“127.0.0.1:11211”在代码中,我在我的系统上得到了这个结果-

我应该从这些数据中解释什么?我在开始时间部分收到警告-
Warning:date():依赖系统的时区设置是不安全的。您*必须*使用date.timezone设置或…

到目前为止,在我看来,连接到默认端口11211的原因是我的cakePHP项目代码中不允许的。但同样,memcache.php如何连接到memcache服务器并显示这些数据

更多详细信息

多亏了都铎·康斯坦丁(Tudor Constantin),telnet 127.0.0.1 11211不再抛出任何错误,显示了一个空屏幕。。。我想这很好

我进一步检查了代码,我们有这样的逻辑模型函数-

echo "<pre>";
echo "checking";
error_reporting(-1); 
$this->Memcache->set($key,$countryNetworkWiseReportData,3600);
echo "finished";
exit;
return @$this->_Memcache_cluster_new->set($key, $var, 0, time()+$expires);
因此,我进入了类CakeMemcache()的set()函数,最后有一行

$this->Memcache = new CakeMemcache();
$this->Memcache->_connect();
这返回false,我不知道从这里调试什么

另一件让我困惑的事情是app_model.php中的memcacheCommon()有以下几行——

$this->_Memcache_standalone =& new Memcache();
$this->_Memcache_cluster_new =& new Memcache();
Notice: memcache_connect(): Server localhost (tcp 11211) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Warning: memcache_connect(): Can't connect to localhost:11211, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Connection to memcached failed
在CakeMemcache()->_connect()内部,有以下几行——

$this->_Memcache_standalone =& new Memcache();
$this->_Memcache_cluster_new =& new Memcache();
Notice: memcache_connect(): Server localhost (tcp 11211) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Warning: memcache_connect(): Can't connect to localhost:11211, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Connection to memcached failed
我不知道他们到底做什么

我会很感激你的指点。。。谢谢

更多详细信息

不知何故,我丢失了先前的memcache.php文件,使用该文件,我获得了上面的memcache使用情况图形显示(上面已经发布了我获得的输出的图片)。我后来从下载了memcache-3.0.6,并尝试运行example.php和memcache.php文件,这些文件存在于归档文件中

首先,运行example.php会给我以下错误-

Notice: Use of undefined constant values - assumed 'values' in path\to\file\memcache.php on line 57
Cant connect to:v:a
我检查了memcached服务是否正在运行(在windows服务列表中)。 另外,
telnet localhost 11211
没有给出任何错误,并显示一个空的命令窗口

其次,运行memcache.php并输入凭据,单击所有选项卡(刷新数据、查看主机统计数据、变量)后,我得到以下信息-

第57行是-

Cant connect to:mymemcache-server1:11211
这是怎么回事,我从网上下载的。在我将其更改为
返回$value之后我得到->

STAT pid 1584
STAT uptime 2856
STAT time 1315981346
STAT version 1.2.1
STAT pointer_size 32
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 1
STAT total_connections 3
STAT connection_structures 2
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
END
。我不记得我是如何更早地得到memcache服务器图的(我在上面贴了这张图片)

第三个,在命令行上,通过telnet连接后,command
stats
给出以下信息-

telnet 127.0.0.1 11211

如我所见,您在windows计算机上,因此telnet命令是:

# Memcache server constants
define('MEMCACHE_SERVER', 'localhost:11211');
define('MEMCACHE_SERVER_CLUSTER', 'localhost:11211');
define('MEMCACHE_SERVER_CLUSTER_NEW', 'localhost:11211');

注意空格而不是冒号。这可能有助于调试memcache连接

耶!我找到了解决办法!!在我将
/app/config/fcore.php
文件中的
localhost
更改为
127.0.0.1
后,它开始工作

作出以下更改—

# Memcache server constants
define('MEMCACHE_SERVER', '127.0.0.1:11211');
define('MEMCACHE_SERVER_CLUSTER', '127.0.0.1:11211');
define('MEMCACHE_SERVER_CLUSTER_NEW', '127.0.0.1:11211');

哦,我为此遭受了太多的痛苦,我想我这辈子都无法解决这个问题


幸运的是,我们的团队使用
127.0.0.1
而不是
localhost
为项目设置了一个新的存储库,当我使用checkout时,memcache开始工作,后来我意识到这就是原因。

请查看问题中我的进一步详细信息部分我与您Sandepan有smillar问题。我在Telnetware上看不到任何东西。我可以从哪里获取您正在显示的memcache.php脚本?@Neo,您可以从->下载最新链接获取它。提取归档文件,将其中的
memcache.php
文件放入web目录并浏览memcache.php。应该安装PECL。在cake配置中,memcache服务器的设置在哪里?Memcache可以有一个服务器集群,通常一个类包装器会遍历Memcache服务器列表并尝试连接到它们。@gview-发布了一些详细信息。@Neo-发布了一些详细信息。