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


Reply via email to