2010-09-18 50 views
3

每次我尝试使用add()函数memcached的,我得到以下错误:PHP memcached的错误

A PHP Error was encountered 

Severity: Warning 

Message: MemcachePool::add(): The lowest two bytes of the flags array is reserved for pecl/memcache internal use 

Filename: libraries/memcached_library.php 

Line Number: 92 

出了什么问题?我正在使用这个库codeigniter:http://github.com/trs21219/memcached-library

回答

13

你在64位?看起来这是最近发现的pecl/memcache错误:http://pecl.php.net/bugs/bug.php?id=18567

看起来好像它与压缩标志有关。它不可能是一个布尔值了,它需要根据this source code

/** 
* The compressed argument on Memcache::add, Memcache::set and Memcache::replace takes 
* an integer not a boolean. Since pecl/memcache 3.0.3 booleans now leads to warnings like 
* The lowest two bytes of the flags array is reserved for pecl/memcache internal use 
*/ 
+2

完美。谢谢。我将压缩从TRUE更改为0,现在一切正常。 – Matthew 2010-09-18 12:20:25

+0

我在Windows上使用Memcache并面临同样的问题。只需重复一遍,如果传递需要0来解决它,'Compression'将是第三个参数。 Ref:http://php.net/manual/en/memcache.set.php – kta 2016-11-20 11:52:46

5

您可以添加“假”作为第三个参数,它的工作对我来说是一个整数。

Warning (2): MemcachePool::add() [memcachepool.add]: The lowest two bytes of the flags array is reserved for pecl/memcache internal use 

From: 
return $this->memcache->add($name, $value, $expiry); 

To: 
return $this->memcache->add($name, $value, false, $expiry); 
+0

是的,PHP中的Memcache和Memcached方法有所不同 – 2014-09-10 10:34:37

5

可能是你的情况:一些手册内存缓存使用,像http://www.codeforest.net/how-to-install-memcached-on-windows-machine,有错误

$memcache->add("key", $tmp, 30); 

正确使用截止秒参数(30秒这里)是:

$memcache->add("key", $tmp, MEMCACHE_COMPRESSED, 30); 

或类似

$memcache->add("key", $tmp, false, 30); 

与正确的示例性的手动样本:http://zurmo.org/wiki/installing-memcache-on-windows
也文档http://php.net/manual/ru/memcache.add.php

见对我来说这是关键。

1

这可能对一些人有所帮助,我已经下载了一个codeigniter库,它使用了memcache而不是会话的memcache。它可以在这里找到:https://github.com/pierskarsenbarg/codeigniter-session-memcached

对我来说,问题是,LIB使用

memcache->set() 

和/或

memcache->replace() 

当第三个参数是到期时间,而不是一个有效的标志类型。

即MEMCACHE_COMPRESSED

原始编码:

$this->memcache->set('user_session_data' . $this->userdata['session_id'], $this->userdata, $this->sess_expiration); 

改变的代码:

$this->memcache->set('user_session_data' . $this->userdata['session_id'], $this->userdata, MEMCACHE_COMPRESSED, $this->sess_expiration); 

改变第三参数为正确的标志之后键入错误去远。

+1

你的回答其实跟我一样,但是关于codeigniter memcached功能的bug。我认为它也有用 - upvote。 – FlameStorm 2016-04-21 21:51:18