Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ed833c9f
Commit
ed833c9f
authored
Oct 23, 2019
by
antirez
Browse files
Modules hooks: implement the FLUSHDB event.
parent
8ec2fc39
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
ed833c9f
...
...
@@ -350,6 +350,12 @@ long long emptyDbGeneric(redisDb *dbarray, int dbnum, int flags, void(callback)(
return
-
1
;
}
/* Fire the flushdb modules event. */
RedisModuleFlushInfoV1
fi
=
{
REDISMODULE_FLUSHINFO_VERSION
,
!
async
,
dbnum
};
moduleFireServerEvent
(
REDISMODULE_EVENT_FLUSHDB
,
REDISMODULE_SUBEVENT_FLUSHDB_START
,
&
fi
);
/* Make sure the WATCHed keys are affected by the FLUSH* commands.
* Note that we need to call the function while the keys are still
* there. */
...
...
@@ -380,6 +386,13 @@ long long emptyDbGeneric(redisDb *dbarray, int dbnum, int flags, void(callback)(
}
}
if
(
dbnum
==
-
1
)
flushSlaveKeysWithExpireList
();
/* Also fire the end event. Note that this event will fire almost
* immediately after the start event if the flush is asynchronous. */
moduleFireServerEvent
(
REDISMODULE_EVENT_FLUSHDB
,
REDISMODULE_SUBEVENT_FLUSHDB_END
,
&
fi
);
return
removed
;
}
...
...
src/module.c
View file @
ed833c9f
...
...
@@ -5721,8 +5721,8 @@ void ModuleForkDoneHandler(int exitcode, int bysignal) {
* because of replication, after the replica synchronization)
* happened. The following sub events are available:
*
* REDISMODULE_EVENT_FLUSH
ALL
_START
* REDISMODULE_EVENT_FLUSH
ALL
_END
* REDISMODULE_EVENT_FLUSH
DB
_START
* REDISMODULE_EVENT_FLUSH
DB
_END
*
* The data pointer can be casted to a RedisModuleFlushInfo
* structure with the following fields:
...
...
src/redismodule.h
View file @
ed833c9f
...
...
@@ -239,6 +239,9 @@ static RedisModuleEvent
#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_CONNECTED 0
#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_DISCONNECTED 1
#define REDISMODULE_SUBEVENT_FLUSHDB_START 0
#define REDISMODULE_SUBEVENT_FLUSHDB_END 1
/* RedisModuleClientInfo flags. */
#define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0)
#define REDISMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment