memcached's operations are all atomic. Always have been, always will be, barring bugs.
Wouldn't be much useful to anyone if you could have a get come back with half a set... I answer this question a lot and it's pretty bizarre that people think it's how it works. Internally, items are generally immutable (except in one case). If you "set" a new object in place of an old one, new memory is assigned, the old one is removed from the hash table, and the new one put into it. The old one sticks around so long as anyone is still reading from it, then it is garbage collected (via refcounts). Reads are always consistent and writes don't clobber each other. That would be *insane*. The only exception is incr/decr, which will rewrite the existing item if nobody else is accessing it at the time. If it is being accessed, it allocates new memory as normal. I wonder if I should bump this answer higher up on the wiki somewhere? It's kind of a silly question but it does keep getting asked... On Mon, 12 May 2014, Ezekiel Victor wrote: > OK I just noticed that Membase is now Couchbase, but the point remains. Also > one of the things we talked about is if the server dies in the middle > of a write, what level of protection do you have for the data that would have > been written? I guess this discussion would be more about Couchbase > at this point. > > On Monday, May 12, 2014 2:33:29 PM UTC-7, Ezekiel Victor wrote: > A coworker and I were having a discussion about whether to use MySQL or > memcached for a key-value store. My view is that memcached is > designed to be exactly that, and if we desire persistence we can use > Membase. He alleged that memcached lacks read/write consistency, > such that you can end up reading a half-value if you were to read in > the middle of a write. Is this true? I have used memcached under > many thousands of reads/writes per second on a high traffic site and > never ran into any such problem. > > -- > > --- > You received this message because you are subscribed to the Google Groups > "memcached" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > > -- --- You received this message because you are subscribed to the Google Groups "memcached" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
