127.0.0.1:6379> keys *
(empty array)127.0.0.1:6379> multi
OK
127.0.0.1:6379(TX)>set a1 v1
QUEUED
127.0.0.1:6379(TX)>set a2 v2
QUEUED
127.0.0.1:6379(TX)>set a3 v3
QUEUED
127.0.0.1:6379(TX)>exec1) OK
2) OK
3) OK
127.0.0.1:6379> keys *
1)"a2"2)"a1"3)"a3"127.0.0.1:6379>
2、Redis事务错误处理
127.0.0.1:6379> keys *
1)"a2"2)"a1"3)"a3"127.0.0.1:6379> multi
OK
127.0.0.1:6379(TX)>set a4 v4
QUEUED
127.0.0.1:6379(TX)>set a5
(error) ERR wrong number of arguments for'set'command127.0.0.1:6379(TX)>set a6 v6
QUEUED
127.0.0.1:6379(TX)>exec(error) EXECABORT Transaction discarded because of previous errors.
127.0.0.1:6379> keys *
1)"a2"2)"a1"3)"a3"127.0.0.1:6379>
3、Redis事务错误处理,在执行阶段出错不会回滚
127.0.0.1:6379> keys *
1)"a2"2)"a1"3)"a3"127.0.0.1:6379> multi
OK
127.0.0.1:6379(TX)>set a4 v4
QUEUED
127.0.0.1:6379(TX)> incr a4
QUEUED
127.0.0.1:6379(TX)>set a5 v5
QUEUED
127.0.0.1:6379(TX)>exec1) OK
2)(error) ERR value is not an integer or out of range
3) OK
127.0.0.1:6379> keys *
1)"a1"2)"a4"3)"a2"4)"a5"5)"a3"127.0.0.1:6379> get a4
"v4"127.0.0.1:6379>