简体   繁体   English

Redis 集群键空间如何工作? 无法接收 redis 过期事件

[英]how does Redis cluster keyspace work? can't recive redis expired event

according to the document ( https://redis.io/docs/manual/keyspace-notifications/ )根据文档( https://redis.io/docs/manual/keyspace-notifications/

Events in a cluster集群中的事件

Every node of a Redis cluster generates events about its own subset of the keyspace as described above.如上所述,Redis 集群的每个节点都会生成有关其自己的键空间子集的事件。 However, unlike regular Pub/Sub communication in a cluster, events' notifications are not broadcasted to all nodes.但是,与集群中的常规 Pub/Sub 通信不同,事件的通知不会广播到所有节点。 Put differently, keyspace events are node-specific.换句话说,键空间事件是特定于节点的。 This means that to receive all keyspace events of a cluster, clients need to subscribe to each of the nodes .这意味着要接收集群的所有键空间事件,客户端需要订阅每个节点

Does this mean that I should subscribe to the slave nodes?这是否意味着我应该订阅从节点? Besides master node?除了主节点?

For example, if it is an expired event例如,如果它是一个过期事件

Slave nodes only replicates master nodes, and when the data expires, doesn't the event occur in master nodes?从节点只复制主节点,当数据过期时,主节点不发生事件吗? Shouldn't I just only subscribe to the master nodes?我不应该只订阅主节点吗?

Why should I subscribe to all nodes?为什么要订阅所有节点?

Does this mean that I should subscribe to the slave nodes?这是否意味着我应该订阅从节点? Besides master node?除了主节点?

It means you need to subscribe to all master nodes in the cluster.这意味着您需要订阅集群中的所有主节点。

Does this mean that I should subscribe to the slave nodes?这是否意味着我应该订阅从节点? Besides master node?除了主节点?

No. Normally you don't want to subscribe to slave nodes.不。通常你不想订阅从节点。 Because slave nodes might send different notification messages from master nodes.因为从节点可能会从主节点发送不同的通知消息。 See the following for example.请参阅以下示例。

Slave nodes only replicates master nodes, and when the data expires, doesn't the event occur in master nodes?从节点只复制主节点,当数据过期时,主节点不发生事件吗? Shouldn't I just only subscribe to the master nodes?我不应该只订阅主节点吗?

When data is expired, subscriber on master node will get an expired notification.当数据过期时,主节点上的订阅者会收到过期通知。 When master expires the key, it will send a del command to slave node, so that slave will delete (expire) the key.当master过期key时,会向slave发送del命令,slave会删除(过期)key。 Since slave node receives a del command, subscriber on slave node will get a del notification.由于slave节点收到del命令,slave节点上的订阅者会收到del通知。 That's the different.那是不同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM