Hello folks, As far as I know, currently if we do FLUSHDB/FLUSHALL/SWAPDB these three operations, there is no keyspace event notification sent to the subscribed client. But for these three operations the keyspace actually "changed". may I ask is this an intended behaviour, or is this a bug? Thanks.

Comment From: itamarhaber

Hello @daidaotong

I would guess this is intended as keyspace notifications are about individual keys rather than the "space" itself. That said, what would be the use case for such notifications, were they to be added, to the application/user?

Comment From: daidaotong

@itamarhaber hello Itamar, we have a feature that needs to support notification mechanism for every change in the keyspace(not only for a single key), but currently this feature doesn't work if we use keyspace notifications. thanks

Comment From: itamarhaber

May I ask what your feature's purpose is? Could you describe the reasoning for needing to catch such events? Is it related to security?

In any case, I'll mark this as a feature request to see if there additional interest in these types of events. Also, note that the Redis module API can be used for implementing this functionality as a custom module.

Comment From: oranagra

@daidaotong maybe the client side caching invalidation messages are what you're looking for? it does send an invalidation message when the keyspace is flushed. recently improved in https://github.com/redis/redis/pull/7469

Comment From: daidaotong

thank you @itamarhaber @oranagra , the use case is indeed related to security, we need to have a monitoring system which needs to catch all the keyspace related changes, and record this information.. However, based on the current Redis provided feature it seems like this is not an easy task. firstly, the module approach @itamarhaber mentioned earlier doesn't work easily since some keyspace changes such as SWAPDB is missing event hooks, which I believe should be similar to FLUSHDB ServerEvent for Module. Secondly please correct me if I am wrong @oranagra , the client side caching is supposed to work with caching invalidation in client-side, although it has hooks for flushdb, client-side need to maintain a separate connection for subscribing the invalidation message, also it seems like doesn't really hit our use cases. I think it would be a good idea to introduce a separate keyspace event mechanism for letting client-side get all different kinds of keyspace changes. Thanks

Comment From: oranagra

@daidaotong FYI, a SWAPDB module hook was added in https://github.com/redis/redis/pull/7804 i suppose that if your use case is security, you can't really rely on PUBSUB or CSC since a client can get disconnected and you may lose some events before re-connecting.

Comment From: daidaotong

Thanks @oranagra for the update! right the PUB/SUB is not guaranteed to deliver messages, so currently we kind of building a separate application to get all the keys a certain period of time from slaves, but this is kind of cumbersome. Please let me know if there are any other ways for this , thanks.

Comment From: oranagra

btw, this may also be some day covered by https://github.com/redis/redis/issues/5766