For Redis-Cluster subscribe expire keyevent

415 views
Skip to first unread message

Andrew Cheng

unread,
Jul 23, 2018, 11:03:59 AM7/23/18
to lettuce-redis-client-users
我很难通过lettuce5.0.4RELEASE.i订阅redis-cluster。就像wiki一样。但是我刚刚收到了使用“PUBLISH __keyevent @ 0 __:expired”的事件。我找不到任何有用的方法来制作redis集群听到expire keyevent.could任何人都可以给我一些帮助。
这里显示了一些代码。

Xnip2018-07-23_23-01-24.jpg
Xnip2018-07-23_23-01-49.jpg
Xnip2018-07-23_23-02-20.jpg

Mark Paluch

unread,
Jul 24, 2018, 3:01:51 AM7/24/18
to lettuce-redis-client-users, Andrew Cheng
Hi Andrew, 

Please note the language of this forum is English and the majority does not understand most asian languages.

Cheers, 
Mark
Am 23. Juli 2018, 17:04 +0200 schrieb Andrew Cheng <hcc1...@gmail.com>:
我很难通过lettuce5.0.4RELEASE.i订阅redis-cluster。就像wiki一样。但是我刚刚收到了使用“PUBLISH __keyevent @ 0 __:expired”的事件。我找不到任何有用的方法来制作redis集群听到expire keyevent.could任何人都可以给我一些帮助。
这里显示了一些代码。

--
You received this message because you are subscribed to the Google Groups "lettuce-redis-client-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lettuce-redis-clien...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lettuce-redis-client-users/d18c4241-349e-4d60-8329-cd9904de233f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Cheng

unread,
Jul 26, 2018, 10:51:12 AM7/26/18
to lettuce-redis-client-users
Hi Mark
Sorry,i don't know why the msg convert to chinese ,actually ,i use Lettuce.io 5.0.3RELEASE and also read the description about cluster pub/sub .I do the same with wiki,but i only received the msg from the cluster node which i subscribe.From code comment about "StatefulRedisClusterConnection" i saw "Due to Redis Cluster's nature,messages are broadcasted across the cluster and a client can connect to any arbitrary node to participate with a subscription." .that's my code,and i wish get help from yous.

Thanks.

On Tuesday, July 24, 2018 at 3:01:51 PM UTC+8, Mark Paluch wrote:
Hi Andrew, 

Please note the language of this forum is English and the majority does not understand most asian languages.

Cheers, 
Mark
Am 23. Juli 2018, 17:04 +0200 schrieb Andrew Cheng <hcc1...@gmail.com>:
我很难通过lettuce5.0.4RELEASE.i订阅redis-cluster。就像wiki一样。但是我刚刚收到了使用“PUBLISH __keyevent @ 0 __:expired”的事件。我找不到任何有用的方法来制作redis集群听到expire keyevent.could任何人都可以给我一些帮助。
这里显示了一些代码。

--
You received this message because you are subscribed to the Google Groups "lettuce-redis-client-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lettuce-redis-client-users+unsub...@googlegroups.com.

Mark Paluch

unread,
Aug 3, 2018, 3:34:09 AM8/3/18
to lettuce-redis-client-users
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
Reply all
Reply to author
Forward
0 new messages