Strange return codes from PHP memcache set functions

Brian Moon brianm at
Mon Nov 20 20:52:06 UTC 2006

Anthony Volodkin wrote:
> Hi,
> For the future readers of this list:
> It seems that the issue I ran into can happen if you try to store a 0 
> (as a value) using PHP/memcached.
> The 0 will get stored correctly, however, several things may happen upon 
> your attempt to retrieve this 0:
> - The memcache client may attempt to failover (if enabled+using multiple 
> servers) onto another server (potentially causing subsequent memcache 
> accesses to fail)
> - Because a 0 is also "false" error-detecting code (a simple "or" 
> example below) will be triggered making it difficult to tell if you 
> really received a 0 or whether something failed.
> So there, hopefully will save someone some debugging. :)

You should be checking your memcached return values using ===

$var = $cache->get("key");


Brian Moon
It's good to be cheap =)

More information about the memcached mailing list