how to lock between different actions on a distributed environment

41 views
Skip to first unread message

Michal Singer

unread,
May 1, 2012, 6:44:58 AM5/1/12
to spymem...@googlegroups.com


Hi, I would like to know if thereis a way to perform "set" and "get"

actions from different memcachedclients in some atomic way.

So that if 2 clients set the samekey in the memcached the behavior is ok and a client  that performs the get will see the latestchange.
 
thanks

ingenthr

unread,
May 2, 2012, 1:55:35 AM5/2/12
to spymem...@googlegroups.com
In memcached, there is no lock per se, but there are CAS operations.  With these, you'd see the failure of one of two actors trying to do a set at the same time.  One would succeed, the other would fail.  Frequently that'll solve what you need.

Also, note that the Couchbase Java Client which extends this client does have a get with lock and unlock.  Still, if you can work your logic in to use CAS, you'll be better off.
Reply all
Reply to author
Forward
0 new messages