Redis 命令

DISCARD

Discard all commands issued after MULTI

127.0.0.1:6379> MGET bank:A:account bank:B:account
1) "400"
2) "600"
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> DECRBY bank:A:account 100
QUEUED
127.0.0.1:6379> INCRBY bank:B:account 100
QUEUED
127.0.0.1:6379> DISCARD
OK
127.0.0.1:6379> MGET bank:A:account bank:B:account
1) "400"
2) "600"

More: http://redis.io/commands/discardhttp://www.redis.cn/commands/discard.html

EXEC

Execute all commands issued after MULTI

127.0.0.1:6379> MSET bank:A:account 500 bank:B:account 500
OK
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> DECRBY bank:A:account 100
QUEUED
127.0.0.1:6379> INCRBY bank:B:account 100
QUEUED
127.0.0.1:6379> EXEC
1) (integer) 400
2) (integer) 600

More: http://redis.io/commands/exechttp://www.redis.cn/commands/exec.html

MULTI

Mark the start of a transaction block

127.0.0.1:6379> MSET bank:A:account 500 bank:B:account 500
OK
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> DECRBY bank:A:account 100
QUEUED
127.0.0.1:6379> INCRBY bank:B:account 100
QUEUED
127.0.0.1:6379> EXEC
1) (integer) 400
2) (integer) 600

More: http://redis.io/commands/multihttp://www.redis.cn/commands/multi.html

UNWATCH

Forget about all watched keys

127.0.0.1:6379> WATCH key
OK
......
......
......
127.0.0.1:6379> UNWATCH
OK

More: http://redis.io/commands/unwatchhttp://www.redis.cn/commands/unwatch.html

WATCH key [key ...]

Watch the given keys to determine execution of the MULTI/EXEC block

127.0.0.1:6379> SET key 1
OK
127.0.0.1:6379> WATCH key
OK
127.0.0.1:6379> SET key 2
OK
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> SET key 3
QUEUED
127.0.0.1:6379> EXEC
(nil)
127.0.0.1:6379> GET key
"2"

More: http://redis.io/commands/watchhttp://www.redis.cn/commands/watch.html

原文地址:https://www.cnblogs.com/huey/p/4351064.html