node_redis: SMEMBERS 阻塞了吗?

node_redis: is SMEMBERS blocking?

Redis下的SCAN documentation, it mentions this about SMEMBERS:

However while blocking commands like SMEMBERS are able to provide all the elements that are part of a Set in a given moment, The SCAN family of commands only offer limited guarantees about the returned elements since the collection that we incrementally iterate can change during the iteration process.

令人惊讶的是,我找不到任何关于 SMEMBERS 如何阻止以及何时避免使用它的其他信息。如果 SMEMBERS 是一个阻塞调用,在 node_redis 中使用是否安全,或者阻塞 Redis 最终也会阻塞 Node 的线程吗?

有点关系,如果SSCAN is the best practice instead of calling SMEMBERS, is there an equivalent SCAN call for SINTER?

提前致谢

几乎所有 Redis 的命令都是阻塞的,SCAN 包括在内(但它保证了较短的执行时间)。唯一非阻塞的命令是由其他线程执行的命令(当前仅与持久性相关,例如 BGSAVE)。

具体来说,SMEMBERS 正在阻塞。如果您的 Set 不是太大(可能是几 K(),这可能没问题。如果 Set 变得太大,Redis 将在准备回复时阻塞,并在发送回之前消耗 RAM 来缓冲它。在这种情况下,建议使用 SSCAN 遍历 Set 以允许其他请求在对它的调用之间交错。