diff options
author | Wen Hui <wen.hui.ware@gmail.com> | 2020-09-20 06:36:20 -0400 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2020-10-27 09:12:01 +0200 |
commit | 88441019a535a4fa11c28b660adacf5ccc6f6b9b (patch) | |
tree | 93ee744f2a02f0d32d22944bbe8a9704f718aeaa /tests/modules | |
parent | aa1feec746d40d7a7446919029e4220f87c09d41 (diff) | |
download | redis-88441019a535a4fa11c28b660adacf5ccc6f6b9b.tar.gz |
Add Swapdb Module Event (#7804)
(cherry picked from commit dfe9714c867ba69f9ace30c9a9270ae95a111556)
Diffstat (limited to 'tests/modules')
-rw-r--r-- | tests/modules/hooks.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/modules/hooks.c b/tests/modules/hooks.c index 665a20481..54f84aa23 100644 --- a/tests/modules/hooks.c +++ b/tests/modules/hooks.c @@ -253,6 +253,16 @@ void moduleChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, LogStringEvent(ctx, keyname, ei->module_name); } +void swapDbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) +{ + REDISMODULE_NOT_USED(e); + REDISMODULE_NOT_USED(sub); + + RedisModuleSwapDbInfo *ei = data; + LogNumericEvent(ctx, "swapdb-first", ei->dbnum_first); + LogNumericEvent(ctx, "swapdb-second", ei->dbnum_second); +} + /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { @@ -289,6 +299,8 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) RedisModuleEvent_CronLoop, cronLoopCallback); RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_ModuleChange, moduleChangeCallback); + RedisModule_SubscribeToServerEvent(ctx, + RedisModuleEvent_SwapDB, swapDbCallback); event_log = RedisModule_CreateDict(ctx); |