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:

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

References:
http://us1.php.net/manual/en/memcache.set.php
https://bugzilla.mozilla.org/show_bug.cgi?id=634219
https://drupal.org/node/163277

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