Redis transaction support

Redis transaction support

WATCH

UNWATCH

MULTI

EXEC

DISCARD

During the running of a transaction, two types of command errors may be encountered:

A command may fail when it is put in the queue. Therefore, the transaction may cause an error before the EXEC command is called. For example, this command may have syntax errors (the number of parameters is incorrect, the command name is incorrect, etc.), or there may be some critical conditions (for example: if you use the maxmemory command to configure the memory limit for the Redis server, then it may be There is a memory overflow condition).
After calling the EXEC command, a certain command in the transaction may fail to execute. For example, we performed an operation of the wrong type on a key (for example, a List type operation was performed on a String type key).

You can use the Redis client to detect the first type of error. Before calling the EXEC command, these clients can check the return value of the command placed in the queue: if the return value of the command is a QUEUE string, it means that it has been correct Put this command in the queue; otherwise, Redis will return an error. If an error occurs when placing a command in the queue, most clients will abort the transaction and discard the transaction.

Guess you like

Origin blog.csdn.net/u014553029/article/details/108626362