In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Affairs
MULTI, EXEC, DISCARD, and WATCH are commands related to Redis transactions. A transaction can execute multiple commands at once, with two important guarantees:
A transaction is a single isolated operation: all commands in the transaction are serialized and executed sequentially. Transaction execution is not interrupted by command requests from other clients.
A transaction is an atomic operation: all or none of the commands in the transaction are executed.
The EXEC command is responsible for triggering and executing all commands in the transaction:
If the client opens a transaction using MULTI and fails to execute EXEC because of a break, then all commands in the transaction will not be executed.
On the other hand, if the client successfully executes EXEC after opening the transaction, all commands in the transaction are executed.
When using AOF persistence, Redis writes the transaction to disk using a single write(2) command.
However, if the Redis server is killed by an administrator for some reason, or some hardware failure occurs, it is likely that only some of the transaction commands will be successfully written to disk.
If Redis finds such a problem with the AOF file on restart, it will exit with an error.
Using the redis-check-aof program fixes this problem: it removes incomplete transaction information from the AOF file, ensuring that the server can start smoothly.
Starting with version 2.2, Redis can also implement CAS (check-and-set) operations through optimistic locks. For details, please refer to the second half of the document. Redis transactions can execute a series of scripts with two important guarantees:
Batch of commands Before the Exec command, any command in the transaction fails to execute, and the rest of the commands are still executed. During transaction execution, command requests submitted by other clients are not inserted into the transaction execution command sequence.
A transaction goes through three stages from start to execution: start-enqueue-execute. This article describes the common commands for Redis transactions.
DISCARD cancels the transaction, abandoning execution of all commands within the transaction block. The command is executed as follows. Select a command and execute it to cancel
Exec Command: Executes all script commands. The return values of all commands within a transaction block, arranged in the order in which the commands were executed. Returns nil when the operation is interrupted.
#Monitor key and transaction executed successfully. Changes in the value of Key and execution of transactions can be monitored.
#Monitor key and interrupt transaction execution. You can monitor the execution of transactions, as well as the interruption of transactions.
Redis Multi command. Used to mark the beginning of a transaction block. Multiple commands in a transaction block are placed in a queue in order. After entering the complete command, enter the exec command.
The UNwatch command is used to unwatch transactions. When you enter a command to monitor, you can cancel the monitoring of the command with the UNwatch command.
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.