Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is memcached atomic?

Atomic memcached
0
Posted

Is memcached atomic?

0

Of course! Well, lets be specific: • All individual commands sent to memcached are absolutely atomic. If you send a set and a get in parallel, against the same object, they will not clober each other. They will be serialized and one will be executed before the other. Even in threaded mode, all commands are atomic. If they are not, it’s a bug 🙂 • A series of commands is not atomic. If you issue a ‘get’ against an item, operate on the data, then wish to ‘set’ it back into memcached, you are not guaranteed to be the only process working on that value. In parallel, you could end up overwriting a value set by something else. In 1.2.5 and higher there are the “gets” and “cas” commands, which are used to deal with these situations. If you issue a ‘gets’ command to fetch a key, you get a unique identifier back with that value. If you later wish to overwrite the original key, you send that identifier back with the “cas” command. If the identifier stored in memcached is identical to the one you

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.