You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement keyspace notifications for SET and DEL, compatible with Redis notify-keyspace-events.
This PR adds the initial notification emitters and configuration support:
Support K, E, g, $, and A flags, where A currently expands to the implemented event classes g$.
Emit set notifications only when SET actually applies a write, including conditional SET variants.
Emit del notifications only for keys that are actually deleted.
Deduplicate repeated keys in a single DEL, so DEL a a deletes and notifies once.
Queue notifications inside MULTI/EXEC and publish them after a successful commit.
Map notification DB names correctly:
default namespace uses DB 0
redis-databases namespaces map back to Redis DB indexes
This PR only adds notification emitters on primary nodes for SET and DEL, keeping the initial patch small and reviewable. Replica-side notifications and additional commands, if supported, can be added in follow-up PRs.
Unsupported notification classes are rejected for now until their emitters are implemented.
I added optional output parameters to String::Set and Database::MDel so the command layer can emit notifications based on what actually changed.
For SET, this avoids duplicating the conditional SET decision logic in the command layer. For DEL, this avoids an extra EXISTS pass before deletion, which would add unnecessary storage reads and overhead. It also lets MDel return the keys it actually deleted.
The alternative would be to keep these storage APIs unchanged and infer the notification decisions in the command layer. That would keep the APIs smaller, but the trade-off is that SET would duplicate conditional SET/GET logic outside String::Set, and DEL would need extra reads before MDel. Over time, this could also drift from the actual write behavior.
I chose the optional-output approach for this PR, but I’m open to maintainers’ preference here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement keyspace notifications for
SETandDEL, compatible with Redisnotify-keyspace-events.This PR adds the initial notification emitters and configuration support:
K,E,g,$, andAflags, whereAcurrently expands to the implemented event classesg$.setnotifications only whenSETactually applies a write, including conditionalSETvariants.delnotifications only for keys that are actually deleted.DEL, soDEL a adeletes and notifies once.MULTI/EXECand publish them after a successful commit.0redis-databasesnamespaces map back to Redis DB indexesThis PR only adds notification emitters on primary nodes for
SETandDEL, keeping the initial patch small and reviewable. Replica-side notifications and additional commands, if supported, can be added in follow-up PRs.Unsupported notification classes are rejected for now until their emitters are implemented.
Ref Proposal: #3533
Tracking Issue: #2915
Assisted by Codex/GPT-5.5.