127.0.0.1:6379> multi OK 127.0.0.1:6379> set object python QUEUED 127.0.0.1:6379> get object QUEUED 127.0.0.1:6379> exec 1) OK 2) "python" ""
可以看到,输入set命令和get命令后只是加入了队列,待到执行事务后才按照顺序执行。
下面也是一组实际操作,这次输入了错误的命令参数:
1 2 3 4 5 6 7 8 9 10 11 12
127.0.0.1:6379> multi OK 127.0.0.1:6379> set new fire QUEUED 127.0.0.1:6379> get new fire (error) ERR wrong number of arguments for'get'command 127.0.0.1:6379> exec (error) EXECABORT Transaction discarded because of previous errors. 127.0.0.1:6379> get new (nil) 127.0.0.1:6379>
下面还是一组实际操作,这次输入了正确的指令,但是该指令用在了错误的地方:
1 2 3 4 5 6 7 8 9 10 11 12 13
127.0.0.1:6379> multi OK 127.0.0.1:6379> set fire none QUEUED 127.0.0.1:6379> incr fire QUEUED 127.0.0.1:6379> get fire QUEUED 127.0.0.1:6379> exec 1) OK 2) (error) ERR value is not an integer or out of range 3) "none" 127.0.0.1:6379>