Home >Database >Redis >Does redis support rollback?

Does redis support rollback?

藏色散人
藏色散人Original
2019-06-11 11:20:183979browse

Does redis support rollback?

If you have a knowledge background in relational databases, you will discover the fact that while the transaction is running, although the Redis command may fail to execute, Redis will still execute the remainder of the transaction. other commands without performing the rollback operation, you may find this behavior strange.

However, this behavior also has its reasonableness:

Only when the called Redis command has a syntax error, this command will fail to execute (in Redis is able to detect such problems while placing this command in the transaction queue), or perform an operation on a key that does not conform to its data type: in practice, this means that only a program error will cause the Redis command execution to fail, which This type of error is most likely to be discovered during program development and is generally rarely found in a production environment.

Redis has simplified functions within the system to ensure faster running speed because Redis does not require the ability to roll back transactions.

There is a common objection to this behavior of Redis transactions, that is, the program may have defects (bugs). However, you should note that transaction rollback does not resolve any program errors.

For example, if a query increments the value of a key by 2 instead of 1, or increments the wrong key, then the transaction rollback mechanism has no way to solve these program problems. Please note that no one can fix programmer's own errors that may cause Redis command execution to fail. Because these program errors are unlikely to enter the production environment, we choose a simpler and faster method when developing Redis without implementing error rollback.

In short, given that there is no mechanism to avoid errors caused by programmers themselves, and such errors usually do not occur in production environments, Redis chose a simpler and faster without Rollback method to process the transaction.

Recommended: "Redis Video Tutorial"

The above is the detailed content of Does redis support rollback?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to expand redisNext article:How to expand redis