Why does PHP memcache set fail?

A change in PHP Memcache extension 3.0.3 and later requires that you use the integer-constant MEMCACHE_COMPRESSED instead of TRUE for the $flag (third parameter) in your Memcache::set() calls.

If you don’t, it will just fail to send the “set” request to the memcache server entirely. (Hopefully you are checking the return value of your ->set() calls!

After you fix it, test it:

echo "getServerStatus() returns " . $mc->getServerStatus("", 11211) . "\n";
$retval = $mc->set("testval", time() );
echo "set() returned " . ($memcache_result?"TRUE":"FALSE") . "\n";
echo "get() returned " . $mc->get("testval") . "\n";


Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Twitter
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • StumbleUpon