本文内容为 http://www.redis.io/commands/exec 的翻译、注解、例子扩充及其它修改。感谢 Redis 作者 Antirez 为开源社区作出的贡献,本文保证最新、最准、最全以表示对其的敬意。欢迎留言纠错、提示更新或支持。
EXEC

执行(Execute)所有之前正在某个事务过程(Transaction)中等待的命令,并恢复连接状态(Connection state)到正常(Normal)

Executes all previously queued commands in a transaction and restores the connection state to normal.

当同时使用命令 WATCH 时,当前命令只有在所有被观察键未被修改的情况下才执行,可以实现检测后设置(CAS,check and set)机制。

When using WATCH, EXEC will execute commands only if the watched keys were not modified, allowing for a check-and-set mechanism.
  • 返回一组回复,其中每个元素对应于原子事务中一条命令的响应结果。

    Array reply: each element being the reply to each of the commands in the atomic transaction.

    当同时使用命令 WATCH 时,如果执行过程被终止,当前命令将会返回空值响应(Null reply)

    When using WATCH, EXEC can return a Null reply if the execution was aborted.
  • 版本支持

    1.2.0+