It's not possible: memcached operations are atomic, and the contract of add() is to fail if there's already a value for that key.
So if two processes send add("lock:xyz", "1") to a given memcached server at the same time, requests will be serialized internally by memcached: one will succeed an the other will fail.
It's not possible: memcached operations are atomic, and the contract of add() is to fail if there's already a value for that key.
So if two processes send
add("lock:xyz", "1")to a given memcached server at the same time, requests will be serialized internally by memcached: one will succeed an the other will fail.See also http://code.google.com/p/memcached/wiki/FAQ#Is_memcached_atomic?