#123 memcache fails to write data correctly

open
nobody
None
5
2011-07-10
2011-07-10
Andrew Collins
No

memcache fails to write data correctly when compress = true;
When reading it causes this notice:
Notice: Memcache::get(): unable to unserialize data in adodb-memcache.lib.inc.php on line 109

The notice is caused by the data being written incorrectly to the cache, and thus it cannot be read.

FIX:
Line 94:
if (!$this->_memcache->set($filename, $contents, $this->compress, $secs2cache)) {

REPLACE:
if (!$this->_memcache->set($filename, $contents, $this->compress === true ? MEMCACHE_COMPRESSED : 0, $secs2cache)) {

To enable compression the 3rd argument must be 2, to disable it must be 0. 1 (true) is known to be buggy. The value of MEMCACHE_COMPRESSED is 2
See:
http://www.php.net/manual/en/memcache.set.php
http://www.php.net/manual/en/memcache.constants.php

Discussion