简体   繁体   中英

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

according to the document ( 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. However, unlike regular Pub/Sub communication in a cluster, events' notifications are not broadcasted to all nodes. 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. Since slave node receives a del command, subscriber on slave node will get a del notification. That's the different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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