Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the transaction commands in Redis

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you what are the transaction commands in Redis, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

1. Transaction 1.1 MULTI and EXEC commands

Send MULTI commands to declare the transaction; EXEC executes the transaction

Redis does not support transaction rollback

Redis 127.0.0.1 > SET key 1OKredis 127.0.0.1 > SET key 2OKredis 127.0.0.1 > SADD key 3 (error) ERR Operation against a key holding the wrong kind of valueredis 127.0.0.1 > SADD key 3 4 (error) ERR Operation against a key holding the wrong kind of valueredis 127.0.0.1 6379 > SADD keynew 3 (integer) 1redis 127.0.0.1 > MUTIL (error) ERR unknown command 'MUTIL'redis 127.0.0. 1SET keynew 4QUEUEDredis 6379 > MULTIOKredis 127.0.0.1 SET keynew 4QUEUEDredis 6379 > SET keynew 4QUEUEDredis 127.0.0.1 EXEC1) OK2) OKredis 127.0.0.1 SET keynew 4QUEUEDredis 6379 > GET key "3" redis 127.0.1OK2 > GET keynew "4" redis 127.0.0.16379 > 1.2 Watch command

Monitor a key value and, if modified, prevent subsequent transactions from executing. Only defensive in nature.

Redis 127.0.0.1 > SET key 1OKredis 127.0.0.1 > WATCH keyOKredis 127.0.0.1 > MULTIOKredis 127.0.0.1 > SET key 2QUEUEDredis 127.0.0.1 > EXEC1) OKredis 127.0.0.1 > GET key "2" redis 127.0.0.16379 > redis 127.0.0.1 > redis 127.0.0.1 > SET keywatch 1OKredis 127.0.1 > SET keywatch 2OKredis 127.0.1 > WATCH keywatchOKredis 127.0 .0.1nil > SET keywatch 3OKredis 127.0.0.1 > MULTIOKredis 127.0.0.1 > SET keywatch 8QUEUEDredis 127.0.0.1 > EXEC (nil) redis 127.0.0.1 > GET keywatch "3" redis 127.0.1 > these are all the contents of the article "what are transaction orders in Redis"? Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report