Recently developed encountered a problem: the need for Hash in field Altered result, the stitching on valueB valueA, requires two steps:
1. Remove the Hash valueA
2. valueB valueA spliced to the back, to rejoin Hash, covering valueA
While redis is a single-threaded process, but increased when writing point, such as multi-threaded, multi-machine write, it could make stale data.
Thereby requiring redis transactions described in this chapter
MULTI
Mark the beginning of a transaction block.
A plurality of commands within the block transaction based on the order which is put into a queue, and finally by atomic EXEC command (Atomic) is performed.
Available versions:
>= 1.2.0
time complexity:
The (1).
return value:
Always returns OK.
Redis > the MULTI # mark Affairs began the OK Redis > INCR user_id # multiple commands in sequence into the team QUEUED Redis > INCR user_id QUEUED Redis > INCR user_id QUEUED Redis > PING QUEUED Redis > EXEC # execution 1 ) ( Integer ) 1 2 ) ( Integer ) 2 . 3 ) ( Integer ) . 3 . 4 ) PONG