我想用Lua脚本调用替换Redis中的MULTI/EXEC操作,并根据Redis中的脚本编写文档:
Redis uses the same Lua interpreter to run all the commands. Also Redis guarantees that a script is executed in an atomic way: no other script or Redis command will be executed while a script is being executed. This semantics is very similar to the one of MULTI / EXEC. From the point of view of all the other clients the effects of a script are either still not visible or already completed.
据我所知,在这种情况下我可以放弃 MULTI/EXEC 并简化我的程序,或者它更复杂,然后这个,我仍然需要使用它以防万一? (以集群环境为例)
最佳答案
一般来说,使用 Lua 脚本,您可以删除 MULTI/EXEC,前提是 MULTI/EXEC block 仅用于强制隔离(如 ACID 中的隔离)。
集群环境不会改变任何东西,因为 MULTI/EXEC block 仅在实例级别工作。
关于multithreading - 我需要在 Redis 脚本中使用 MULTI/EXEC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20394907/