SETNX 是否总是在哨兵系统的redis master 上执行?

Is the SETNX always executed on redis master in the sentinel system?

想问

  1. 如果 SETNX 命令(NX 测试和 SET)保证在 "Redis Sentinel System" 的上下文中在 redis master 上执行?
  2. 如果保证在 "Redis Sentinel System" 的上下文中是原子的?

阅读文档后我的理解是两者都是肯定的,因为:

谁能 100% 肯定地确认一下,也许可以指出一些文档来消除我的疑虑。 提前致谢!

我可以以 %99.97(3 西格玛)的确定性确认以上内容。

Ad. 1 only the master can accept writes and since SETNX has a set/write component it has to go to the master (because all writes go through the master).

正确,不包括您故意启用写入副本并连接到副本的场景。

Ad. 2 since the SET will be executed on the master it only make sense to check the NX part also on the master (no slaves queried, ever), otherwise it would be unnecessarily time consuming and could undermine atomicity.

是的。