CAS operation

Chris Goffinet goffinet at
Sat Sep 8 08:07:27 UTC 2007

Nice.  Thanks for the tip earlier that brought this on :)

So with every object having a 64 bit unique value, if I call gets, I  
retrieve a value for the object (unique value), then send memcache  
this old value (64 bit unique), new value (new update of object) and  
if the unique is still the same for object, it will push the change?

Chris Goffinet
goffinet at

On Sep 8, 2007, at 12:27 AM, Dustin Sallings wrote:

> 	I just prototyped a pair of operations for implementing CAS in  
> memcached.  This provides atomic updates of arbitrary objects  
> without having to rely on locks.
> 	The idea is that every object will have some unique 64-bit value  
> that can be retrieved with a new command (I called it ``gets'' for  
> some reason).  This value needs to be unique and consistent for a  
> given value within memcached.  It can be a counter or memory address  
> or whatever.
> 	After doing a ``gets'' for a key and getting a response, the client  
> can manipulate the data structure as fit, and use a ``cas''  
> operation to put it back iff it has the same value as retrieved  
> (based on the identifier).  It returns a ``NOT FOUND'' error when  
> there's no value for the key (and then you can try it with an  
> ``add''), or ``EXISTS'' when the identifier does not match (and then  
> you can try again from the ``gets'').
> 	Opinions?
> -- 
> Dustin Sallings

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list