summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLuke Palmer <luke@lukepalmer.net>2022-04-13 04:36:38 -0400
committerGitHub <noreply@github.com>2022-04-13 11:36:38 +0300
commitbb7891f080602fb92197a0f398be71eb7aba9e3c (patch)
tree8e10bb0b29c09543714c5266c7e2ac757aaab442 /tests
parente875ff89ece5ec9d43273b19e3b88e4d36a48ba9 (diff)
downloadredis-bb7891f080602fb92197a0f398be71eb7aba9e3c.tar.gz
Keyspace event for new keys (#10512)
Add an optional keyspace event when new keys are added to the db. This is useful for applications where clients need to be aware of the redis keyspace. Such an application can SCAN once at startup and then listen for "new" events (plus others associated with DEL, RENAME, etc).
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/pubsub.tcl13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl
index 4435a9b1d..ea8964cf3 100644
--- a/tests/unit/pubsub.tcl
+++ b/tests/unit/pubsub.tcl
@@ -390,4 +390,17 @@ start_server {tags {"pubsub network"}} {
r config set notify-keyspace-events EA
assert_equal {AE} [lindex [r config get notify-keyspace-events] 1]
}
+
+ test "Keyspace notifications: new key test" {
+ r config set notify-keyspace-events En
+ set rd1 [redis_deferring_client]
+ assert_equal {1} [psubscribe $rd1 *]
+ r set foo bar
+ # second set of foo should not cause a 'new' event
+ r set foo baz
+ r set bar bar
+ assert_equal "pmessage * __keyevent@${db}__:new foo" [$rd1 read]
+ assert_equal "pmessage * __keyevent@${db}__:new bar" [$rd1 read]
+ $rd1 close
+ }
}