antirez/redis — pull request #1109 by charsyam (2013-05-16 00:51:51+00:00)
Title: Adding tx option in setCommand

1] Why this feature is needed?
- when someone wants redis to use a cache, They will do them following these sequence.
1] write db
2] write redis

but after 1], because of context-switching or some other spending time, they can cause race condition. We assume there are 2 clients A, B

There is no problem.
1) A - Write DB
2) B - Write DB
3) A - Write Redis
4) B - Write Redis

But,

1) A - Write DB
2) B - Write DB
3) B - Write Redis
4) A - Write Redis(Context Switching or other event)

so this time we should use global locking, but I think set tx option will help it

1) A - Write DB (get that time)
2) B - Write DB (get that time)
3) B - Write Redis (with tx time : 1005000)
4) A - Write Redis (with tx time : 1000000) <- so this operation will fail.

of course, it has some drawbacks.
1] using more memory when client use tx option
2] it can just pass "normal set command"
3] rdb format is changed, so previous version can't read next version.

Thank you.