summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorguybe7 <guy.benoish@redislabs.com>2022-04-25 12:05:06 +0200
committerGitHub <noreply@github.com>2022-04-25 13:05:06 +0300
commit21e39ec461cf412609475054a9755941df9365bf (patch)
tree276174009555b860f9b9abad9152fac2aff0a450 /tests/modules
parentbd823c7fa3bce983be79835f9a306d4d7c15e31e (diff)
downloadredis-21e39ec461cf412609475054a9755941df9365bf.tar.gz
Test: RM_Call from within "expired" notification (#10613)
This case is interesting because it originates from cron, rather than from another command. The idea came from looking at #9890 and #10573, and I was wondering if RM_Call would work properly when `server.current_client == NULL`
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/keyspace_events.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/modules/keyspace_events.c b/tests/modules/keyspace_events.c
index 152a2c48c..58670164d 100644
--- a/tests/modules/keyspace_events.c
+++ b/tests/modules/keyspace_events.c
@@ -79,6 +79,17 @@ static int KeySpace_NotificationGeneric(RedisModuleCtx *ctx, int type, const cha
return REDISMODULE_OK;
}
+static int KeySpace_NotificationExpired(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) {
+ REDISMODULE_NOT_USED(type);
+ REDISMODULE_NOT_USED(event);
+ REDISMODULE_NOT_USED(key);
+
+ RedisModuleCallReply* rep = RedisModule_Call(ctx, "INCR", "c!", "testkeyspace:expired");
+ RedisModule_FreeCallReply(rep);
+
+ return REDISMODULE_OK;
+}
+
static int KeySpace_NotificationModule(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) {
REDISMODULE_NOT_USED(ctx);
REDISMODULE_NOT_USED(type);
@@ -233,6 +244,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
return REDISMODULE_ERR;
}
+ if(RedisModule_SubscribeToKeyspaceEvents(ctx, REDISMODULE_NOTIFY_EXPIRED, KeySpace_NotificationExpired) != REDISMODULE_OK){
+ return REDISMODULE_ERR;
+ }
+
if(RedisModule_SubscribeToKeyspaceEvents(ctx, REDISMODULE_NOTIFY_MODULE, KeySpace_NotificationModule) != REDISMODULE_OK){
return REDISMODULE_ERR;
}