Redis Multi Command
The Redis Multi command is used to mark the beginning of a transaction block.
Multiple commands within the transaction block are placed into a queue in order, and are finally executed atomically by the EXEC command.
Syntax
The basic syntax of the redis Multi command is as follows:
redis 127.0.0.1:6379> Multi
Available Versions
>= 1.2.0
Return Value
Always returns OK.
Example
redis 127.0.0.1:6379> MULTI # 标记事务开始 OK redis 127.0.0.1:6379> INCR user_id # 多条命令按顺序入队 QUEUED redis 127.0.0.1:6379> INCR user_id QUEUED redis 127.0.0.1:6379> INCR user_id QUEUED redis 127.0.0.1:6379> PING QUEUED redis 127.0.0.1:6379> EXEC # 执行 1) (integer) 1 2) (integer) 2 3) (integer) 3 4) PONG
Other Extensions