-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default value for KeyspaceEventMessageListener on keyspace event notifications #2671
base: main
Are you sure you want to change the base?
Conversation
…notifications. Users must now explicitly call setKeyspaceNotificationsConfigParameter(:String) to a valid redis.config, notify-keyspace-events value to enable Redis keyspace notifications. This aligns with the Redis servers default setting for notify-keyspace-events in redis.conf, which is disabled by default. Additionally, the default value for KeyExpirationEventMessageListener has been changed to 'Ex', for development-time convenience only. However, users should be aware that any notify-keyspace-events configuration only applies once on Spring container initialization and any Redis server reboot will not remember dynamic configuration modifications applied at runtime. Therefore, it is recommended that users applly infrastructure-related configuration changes directly to redis.conf. Closes #2670
Thank you for your help,
|
The only reason I set the value to a " However, I did set the value for |
thanks for picking up this topic. I agree that, though convenient, the Redis config should not be altered by the message listener. However, I'd rather not change defaults in a minor but wait for the next major release. |
@christophstrobl - Thank you for your feedback. Correct me if I am wrong, but it seems that 1) the Perhaps Even the code suggests we filtering for "expiration-only" events, though the logic (and then this) is very cryptic to me. The logic only seems to be checking for the presence of a valid "key" (i.e. |
Thanks for digging up the documentation, being well aware of the config parameters, my point was about changing defaults in a minor, given there are ways to configure it from outside. |
@christophstrobl - I understood your concern and your point. I was also trying to explain that we are not really changing behavior here since we are still receiving "expiration" events with this configuration. Ideally, Redis clients are not sending any configuration to the servers, otherwise we are going to (possibly) run into situations exactly like this. |
@christophstrobl - I also stumbled upon and noticed this configuration in SD (Redis) Repositories today (i.e. |
d43adc9
to
a71f042
Compare
Closes #2670
NOTE: the next effect of theses changes is preserving the existing behavior.
While the default value for
notifiy-keyspace-events
in the abstract classKeyspaceEventMessageListener
changed from "EA
" to "empty" in this PR, it is anabstract class
in the first place, and users must extend the class with a custom implementation in any case. But, I have reluctantly let the default value for the 1 and only Spring Data Redis provided implementation,KeyExpirationEventMessageListener
, to "Ex
", thereby preserving the existing behavior, i.e. to notify on key expiration events.This change came about because of #2654, which occurs for 2 reasons.
First, the default Redis server configuration setting for
notify-keyspace-events
is "empty" (or, in other words, disabled). Therefore, on Redis server restarts, any configuration supplied at runtime, such as is the case with a Spring Data Redis application when theKeyExpirationEventMessageListener
(or anyKeyspaceEventMessageListener
) is registered in the SpringApplicationContext
, gets lost! This is even the case for theredis-cli
.In addition, any configuration coming from a Spring Data Redis application when a
KeyspaceEventMessageListener
(such asKeyExpirationEventMessageListener
) is declared and registered in the Spring container, only happens once, on initialization. So, when the Redis server restarted, again this configuration is lost!The user should be specifying Redis server (infrastructure) configuration in
redis.conf
, which can then also be managed in version control along with the application.