MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RedisModuleCommandDispatcher

Function RedisModuleCommandDispatcher

app/redis-6.2.6/src/module.c:687–712  ·  view source on GitHub ↗

This Redis command binds the normal Redis command invocation with commands * exported by modules. */

Source from the content-addressed store, hash-verified

685/* This Redis command binds the normal Redis command invocation with commands
686 * exported by modules. */
687void RedisModuleCommandDispatcher(client *c) {
688 RedisModuleCommandProxy *cp = (void*)(unsigned long)c->cmd->getkeys_proc;
689 RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
690
691 ctx.flags |= REDISMODULE_CTX_MODULE_COMMAND_CALL;
692 ctx.module = cp->module;
693 ctx.client = c;
694 cp->func(&ctx,(void**)c->argv,c->argc);
695 moduleFreeContext(&ctx);
696
697 /* In some cases processMultibulkBuffer uses sdsMakeRoomFor to
698 * expand the query buffer, and in order to avoid a big object copy
699 * the query buffer SDS may be used directly as the SDS string backing
700 * the client argument vectors: sometimes this will result in the SDS
701 * string having unused space at the end. Later if a module takes ownership
702 * of the RedisString, such space will be wasted forever. Inside the
703 * Redis core this is not a problem because tryObjectEncoding() is called
704 * before storing strings in the key space. Here we need to do it
705 * for the module. */
706 for (int i = 0; i < c->argc; i++) {
707 /* Only do the work if the module took ownership of the object:
708 * in that case the refcount is no longer 1. */
709 if (c->argv[i]->refcount > 1)
710 trimStringObjectIfNeeded(c->argv[i]);
711 }
712}
713
714/* This function returns the list of keys, with the same interface as the
715 * 'getkeys' function of the native commands, for module commands that exported

Callers

nothing calls this directly

Calls 2

moduleFreeContextFunction · 0.85
trimStringObjectIfNeededFunction · 0.85

Tested by

no test coverage detected