mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Modules hooks: implement the FLUSHDB event.
This commit is contained in:
parent
8ec2fc3969
commit
ed833c9f99
13
src/db.c
13
src/db.c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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_FLUSHALL_START
|
||||
* REDISMODULE_EVENT_FLUSHALL_END
|
||||
* REDISMODULE_EVENT_FLUSHDB_START
|
||||
* REDISMODULE_EVENT_FLUSHDB_END
|
||||
*
|
||||
* The data pointer can be casted to a RedisModuleFlushInfo
|
||||
* structure with the following fields:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user