multithreading - 我需要在 Redis 脚本中使用 MULTI/EXEC

标签 multithreading lua nosql redis atomic

我想用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/

相关文章:

javascript - 查询MongoDB中不存在的字段

java - Java 8中等待状态线程不断增加的原因是什么

java - 在 Java 中 Ping 多台服务器

.net - 在多线程期间检索 Windows 窗体属性

c++ - 如何从 Lua 脚本调用 C++ 函数?

Lua,表的大小(#table_name 或 table.getn(table_name),有时返回 0

r - R 中稀疏矩阵的多核求解

android - 电晕连续震动

mongodb - 基于正则表达式排除 Mongo 字段

database - Cassandra UUID 与 TimeUUID 之间有什么区别