Mat*_*hew 4 php memcached codeigniter
每次我尝试使用memcached的add()函数时,我都会收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
可能有什么不对?我正在使用这个库进行codeigniter:http://github.com/trs21219/memcached-library
Fan*_*nis 14
你是64位吗?它看起来像是pecl/memcache最近发现的错误:http://pecl.php.net/bugs/bug.php?id = 18567
它似乎与压缩标志有关.它不能再是布尔值,根据此源代码需要是一个整数
/**
* 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
*/
Run Code Online (Sandbox Code Playgroud)
可能是你的情况:使用memcache的一些手册,比如http://www.codeforest.net/how-to-install-memcached-on-windows-machine,有一个错误:
$memcache->add("key", $tmp, 30);
Run Code Online (Sandbox Code Playgroud)
但正确使用expiration seconds参数(这里30秒)是:
$memcache->add("key", $tmp, MEMCACHE_COMPRESSED, 30);
Run Code Online (Sandbox Code Playgroud)
或者喜欢
$memcache->add("key", $tmp, false, 30);
Run Code Online (Sandbox Code Playgroud)
正确示例的手册示例:http://zurmo.org/wiki/installing-memcache-on-windows
另请参阅文档http://php.net/manual/ru/memcache.add.php
对我来说这是关键.
您可以添加'false'作为第三个参数,它对我有用.
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);
Run Code Online (Sandbox Code Playgroud)