teleo
unread,Nov 5, 2010, 12:01:02 PM11/5/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Redis DB
A typical scenario: the client fetches data, and, much much later,
needs to update it. The update needs to fail if somebody else already
changed the data.
In SQL world, this is usually done as follows:
1. Run: UPDATE table SET ... WHERE ... AND version/timestamp =
<original version/timestamp>
2. Check the number of modified rows that is returned by the command.
If zero, the update failed.
As I understand, the Redis way is to WATCH the data before the update,
fetch it again, compare it in the client to see if it's stale, only
then either DISCARD or update it and EXEC.
Ideally, it would be possible to do with a single, 'optimistic' write
command (some NoSQL products support this). I can think of two
alternatives:
1. Have Redis support a special timestamp/version hash field (e.g.,
'$version'), and allow at least HSET and HMSET to be conditional on
that field.
2. Support generic predicates, upon which write commands could be
conditional (difficult, but powerful and versatile).
What do you think? This is obviously low priority, but perhaps it
should be considered in the long term.