Skip to content
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

JSON.DEL emits no del event when removing the entire value #1105

Open
martin-cowie opened this issue Oct 9, 2023 · 0 comments
Open

JSON.DEL emits no del event when removing the entire value #1105

martin-cowie opened this issue Oct 9, 2023 · 0 comments

Comments

@martin-cowie
Copy link

The Observation

When listening to the keyspace events for built-in complex data structures (LIST, SET, HASH, etc.) we observe that when a complex value is left empty because of the actions of a command, that the value is removed and a del keyspace event emitted. We can interpret this as evidence that the value has been removed.

Using a Redis list for example: open two CLIs and call them "Listener" and "Actor"

Listener

  1. CONFIG SET notify-keyspace-events AKE
  2. PSUBSCRIBE __keyspace@0__:*

Actor

  1. create a list value LPUSH my:list:value 1 2 3
  2. empty it: 
LPOP my:list:value 3

Listener

1) "pmessage"
2) "__keyspace@0__:*"
3) "__keyspace@0__:my:list:value"
4) "lpush"
1) "pmessage"
2) "__keyspace@0__:*"
3) "__keyspace@0__:my:list:value"
4) "lpop"
1) "pmessage"
2) "__keyspace@0__:*"
3) "__keyspace@0__:my:list:value"
4) "del"

Observe the del event at the tail of the output. This pattern is true across all built in datatypes.

Compared to a RedisJSON value, using the same two Redis CLIs

Listener

  1. CONFIG SET notify-keyspace-events AKE
  2. PSUBSCRIBE __keyspace@0__:*

Actor

  1. create a JSON value 
JSON.SET my:json:value $ '{"life":42}'
  2. delete it: 
JSON.DEL my:json:value

Listener

1) "pmessage"
2) "__keyspace@0__:*"
3) "__keyspace@0__:my:json:value"
4) "json.set"
1) "pmessage"
2) "__keyspace@0__:*"
3) "__keyspace@0__:my:json:value"
4) "json.del"

We observe no del event. As JSON.DEL can also remove subsets of the the RedisJSON value we cannot interpret json.del as proof of the values removal.

Proposal

If a RedisJSON value removed from the database the RedisJSON module should also emit a del event for consistency with built-in datatypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants