Hi Andrew,
there are two things to consider when using Pub/Sub and Redis Cluster:
1. Regular (user-space) Pub/Sub messages are broadcasted across the cluster. If you have two clients and each client is connected to a different cluster node, then one client can publish a message and the other one will receive the message without any special handling required on the client side.
2. Keyspace notifications remain node-local. If a key expires on a particular cluster node, then Redis Cluster does not propagate the message to other cluster nodes. This requires special configuration/handling on your client. You need to be connected and subscribed to the particular node.
You can listen to keyspace notifications with Lettuce's Cluster Pub/Sub connection by enabling node message propagation:
StatefulRedisClusterPubSubConnection<String, String> connection = clusterClient.connectPubSub();
connection.addListener(…);
connection.setNodeMessagePropagation(true);
RedisClusterPubSubCommands<String, String> sync = connection.sync();
sync.masters().commands().psubscribe("__key*__:*");
Cheers,
Mark