Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up关于 redis 没有事务回滚? #491
关于 redis 没有事务回滚? #491
Comments
|
看一下官方文档 https://redis.io/topics/transactions Errors inside a transactionDuring a transaction it is possible to encounter two kind of command errors: However starting with Redis 2.6.5, the server will remember that there was an error during the accumulation of commands, and will refuse to execute the transaction returning also an error during EXEC, and discarding the transaction automatically. Before Redis 2.6.5 the behavior was to execute the transaction with just the subset of commands queued successfully in case the client called EXEC regardless of previous errors. The new behavior makes it much more simple to mix transactions with pipelining, so that the whole transaction can be sent at once, reading all the replies later at once. Errors happening after EXEC instead are not handled in a special way: all the other commands will be executed even if some command fails during the transaction. This is more clear on the protocol level. In the following example one command will fail when executed even if the syntax is right: Why Redis does not support roll backs?If you have a relational databases background, the fact that Redis commands can fail during a transaction, but still Redis will execute the rest of the transaction instead of rolling back, may look odd to you. However there are good opinions for this behavior: Redis commands can fail only if called with a wrong syntax (and the problem is not detectable during the command queueing), or against keys holding the wrong data type: this means that in practical terms a failing command is the result of a programming errors, and a kind of error that is very likely to be detected during development, and not in production. |
|
没懂他的意思,是说redis不支持回滚,但是又保持原子性,这个我没理解 |
首先原子性的定义:事务中的命令要么全部被执行,要么全部都不执行。 然后再看官方文档关键段:
我根据Redis文档理解,认为事务过程中失败有两种可能:
综上:所以Redis 没有事务回滚 |


不一定吧 -> https://blog.csdn.net/yangshangwei/article/details/82866216