mirror of
https://github.com/fluencelabs/redis
synced 2025-06-17 11:11:20 +00:00
Remove the NOTIFY_MODULE flag and simplify the module notification flow if there aren't subscribers
This commit is contained in:
10
src/module.c
10
src/module.c
@ -3748,8 +3748,6 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
|
||||
sub->notify_callback = callback;
|
||||
sub->active = 0;
|
||||
|
||||
/* Let the notification system know that modules are interested in notifications */
|
||||
server.notify_keyspace_events |= NOTIFY_MODULE;
|
||||
listAddNodeTail(moduleKeyspaceSubscribers, sub);
|
||||
return REDISMODULE_OK;
|
||||
|
||||
@ -3759,6 +3757,10 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
|
||||
* This gets called only if at least one module requested to be notified on
|
||||
* keyspace notifications */
|
||||
void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) {
|
||||
|
||||
/* Don't do anything if there aren't any subscribers */
|
||||
if (listLength(moduleKeyspaceSubscribers) == 0) return;
|
||||
|
||||
listIter li;
|
||||
listNode *ln;
|
||||
|
||||
@ -3805,10 +3807,6 @@ void moduleUnsubscribeNotifications(RedisModule *module) {
|
||||
zfree(sub);
|
||||
}
|
||||
}
|
||||
/* If no subscribers are left - do not call the module norification function */
|
||||
if (listLength(moduleKeyspaceSubscribers) == 0) {
|
||||
server.notify_keyspace_events &= ~NOTIFY_MODULE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user