MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RedisModule_OnLoad

Function RedisModule_OnLoad

tests/modules/commandfilter.c:119–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
120 if (RedisModule_Init(ctx,"commandfilter",1,REDISMODULE_APIVER_1)
121 == REDISMODULE_ERR) return REDISMODULE_ERR;
122
123 if (argc != 2) {
124 RedisModule_Log(ctx, "warning", "Log key name not specified");
125 return REDISMODULE_ERR;
126 }
127
128 long long noself = 0;
129 log_key_name = RedisModule_CreateStringFromString(ctx, argv[0]);
130 RedisModule_StringToLongLong(argv[1], &noself);
131
132 if (RedisModule_CreateCommand(ctx,log_command_name,
133 CommandFilter_LogCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
134 return REDISMODULE_ERR;
135
136 if (RedisModule_CreateCommand(ctx,ping_command_name,
137 CommandFilter_PingCommand,"deny-oom",1,1,1) == REDISMODULE_ERR)
138 return REDISMODULE_ERR;
139
140 if (RedisModule_CreateCommand(ctx,unregister_command_name,
141 CommandFilter_UnregisterCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
142 return REDISMODULE_ERR;
143
144 if ((filter = RedisModule_RegisterCommandFilter(ctx, CommandFilter_CommandFilter,
145 noself ? REDISMODULE_CMDFILTER_NOSELF : 0))
146 == NULL) return REDISMODULE_ERR;
147
148 return REDISMODULE_OK;
149}
150
151int RedisModule_OnUnload(RedisModuleCtx *ctx) {
152 RedisModule_FreeString(ctx, log_key_name);

Callers

nothing calls this directly

Calls 1

RedisModule_InitFunction · 0.50

Tested by

no test coverage detected