In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about the affairs in Redis, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
What is a redis transaction?
A Redis transaction can execute multiple commands at once, which is essentially a collection of commands. All commands in a transaction are serialized and then serialized without being inserted into other commands.
Redis provides simple "transaction" capabilities, and multi,exec,discard,watch/unwatch instructions are used to manipulate transactions.
Second, what can Redis transactions do?
In a queue, some sexual, sequential, exclusive execution of a series of commands
How to use the redis command?
1. Transaction-related commands:
(1) DISCARD: cancels the transaction and discards all commands in the transaction block
(2) EXEC: execute commands in the transaction block
(3) MULTI: marks the beginning of a transaction
(4) UNWATCH: cancel the monitoring of all key by the WATCH command
(5) WATCH key [key...]: monitor one (or more) key, and if this (or these) key is changed by other commands before the transaction, the transaction will be interrupted.
2. Transaction error reporting problem:
(1) statement error: an error is reported directly when the queue is added. If this error occurs, the whole transaction will be rolled back.
(2) Logic error: for example, if you give a string + 1, it will report an error only when it is executed. This error will not affect other operations in the transaction, only this article will report an error
3. Watch monitoring:
(1) pessimistic lock
Pessimistic Pessimistic Lock is a very pessimistic lock, every time they go to get the data, they will think that others will modify the operation, leading to overwrite and other problems. So it will be locked every time you get the data, so that if others want to take the data, they will block until the unlock menu can be used after modification. Many of these locking mechanisms are used in traditional relational wake-up databases, such as row locks, table locks, read locks and write locks, which lock the table before doing the operation.
Pessimistic locking ensures data security, but degrades performance
(2) optimistic lock:
Optimistic lock (Optimistic Lock) is an optimistic lock. Every time you go to get the number, you think that others will not modify the data, so it will not be locked. But when you update it, you can judge whether others have updated the data during this period. You can use mechanisms such as "version number" to be optimistic about the types of applications that are read more, which can improve the throughput.
Optimistic strategy: the submitted version must be greater than the currently recorded version before it can be updated
Four and three characteristics
1. Separate isolation operations:
All commands in the transaction are serialized and executed sequentially. During the execution of a transaction, it will not be interrupted by command requests sent by other clients.
2. There is no concept of isolation level:
The commands in the queue will not be actually executed until they are committed, because any instructions will not be actually executed before the transaction is committed, so there is no "query within the transaction to see that it is a physical update. The query outside the transaction cannot see this problem."
3. Atomicity is not guaranteed:
Redis if one command in the same transaction fails, the subsequent command will still be executed without rollback.
(unless there is an error when joining the queue, that is, a compile-time exception similar to java and an exception at execution time will cause a rollback at compile time, and the exception will not be rolled back at execution time)
After reading the above, do you have any further understanding of Redis's affairs? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.