Step 1: Get the current revision pointer
GET foo:1:latest_revision
// Returns foo:1:11
Step 2: Add the new revision and tweak the pointers
MULTI
RENAME foo:1:current foo:1:11 // This came from the first round-trip
SET foo:1:current_revision foo:1:12
SET foo:1:current "This is version 12 of foo:1"
EXEC
The problem here is that because of the two round-trips, I could find myself with an inconsistent state. Is there an atomic approach to the above?
More or less than the same as the ALIAS way.
GET foo:1:current
- I'm sure this can be done in a single round-trip w/ scripting.
- I'm pretty much a redis beginner, but I try.
Just realized that a temporary key can be used to avoid the 2 round-trip issue in the current approach. Still think this syntax would make for some more elegant approaches to certain problems.