Incrementing/decrementing a bogus key
brad at danga.com
Thu Jun 5 19:37:30 UTC 2008
The memcache protocol for increment says:
The data for the item is treated as decimal representation of a 64-bit
unsigned integer. If the current data value does not conform to such a
representation, the commands behave as if the value were 0.
This bit me recently, unknowingly having a Python pickled (serialized) value
in memcache when I thought I had an integer. So I was actually doing an
increment on a serialized integer object, which memcache treats as a zero,
not touching the flags, so when you fetch it back out, you try to
deserialize it, but it's no longer a serialized object and "boom".
I propose we change this edge case of the protocol and make "incr/decr"
return an error (either NOT_FOUND or NOT_NUMBER) if the value wasn't a
decimal representation of a 64-bit unsigned integer. That is, the value
must effectively match /\s*\d+\s*/. (not proposing we add a regex library
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the memcached