随笔 - 458  文章 - 0  评论 - 11  阅读 - 39万

Redis 命令 - Transactions

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

 

posted on   huey2672  阅读(270)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
· 现代计算机视觉入门之:什么是视频
阅读排行:
· 【译】我们最喜欢的2024年的 Visual Studio 新功能
· 个人数据保全计划:从印象笔记迁移到joplin
· Vue3.5常用特性整理
· 重拾 SSH:从基础到安全加固
· 为什么UNIX使用init进程启动其他进程?
< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示