exec
UK[?g?zek] 美[?ɡ'zek]
abbr.execute execution;executive execution
plural: execs
redis EXEC command syntax
Function: Execute all commands in the transaction block.
Syntax: EXEC
Description: If a certain (or some) key is under the monitoring of the WATCH command, and the transaction block If there are commands related to this (or these) key, then the EXEC command will only be executed and take effect when this (or these) key has not been modified by other commands, otherwise the transaction will be aborted.
Available versions: >= 1.2.0
Time complexity: The sum of the time complexity of all commands within the transaction block.
Return: The return value of all commands within the transaction block, arranged in the order of command execution.
When the operation is interrupted, the empty value nil is returned.
redis EXEC command example
# 事務(wù)被成功執(zhí)行 redis> MULTI OK redis> INCR user_id QUEUED redis> INCR user_id QUEUED redis> INCR user_id QUEUED redis> PING QUEUED redis> EXEC 1) (integer) 1 2) (integer) 2 3) (integer) 3 4) PONG # 監(jiān)視 key ,且事務(wù)成功執(zhí)行 redis> WATCH lock lock_times OK redis> MULTI OK redis> SET lock "huangz" QUEUED redis> INCR lock_times QUEUED redis> EXEC 1) OK 2) (integer) 1 # 監(jiān)視 key ,且事務(wù)被打斷 redis> WATCH lock lock_times OK redis> MULTI OK redis> SET lock "joe" # 就在這時,另一個客戶端修改了 lock_times 的值 QUEUED redis> INCR lock_times QUEUED redis> EXEC # 因?yàn)?nbsp;lock_times 被修改, joe 的事務(wù)執(zhí)行失敗 (nil)