Re:Redis: the AK-47 of databases
by IgorPartola on Friday January 28, 2011 @12:40PM
(#2152695)
Ah, that makes sense. I imagine allowing atomic reads without WATCH would complicate the code quite a bit.
Indeed, not very Redis-ish :)
With WATCH is very easy. WATCH this keys. Perform your reads. Prepare to write in a transaction. If at least one key was modified in the meantime the transaction will fail.
You can perform just writes inside the block. If you want atomicity with reads in the middle, you need to use WATCH/MULTI/EXEC that uses an optimistic locking algorithm.