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

Function RM_KeyAtPos

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

When a module command is called in order to obtain the position of * keys, since it was flagged as "getkeys-api" during the registration, * the command implementation checks for this special call using the * RedisModule_IsKeysPositionRequest() API and uses this function in * order to report keys, like in the following example: * * if (RedisModule_IsKeysPositionRequest(ctx)) { *

Source from the content-addressed store, hash-verified

770 * keys are at fixed positions. This interface is only used for commands
771 * with a more complex structure. */
772void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) {
773 if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return;
774 if (pos <= 0) return;
775
776 getKeysResult *res = ctx->keys_result;
777
778 /* Check overflow */
779 if (res->numkeys == res->size) {
780 int newsize = res->size + (res->size > 8192 ? 8192 : res->size);
781 getKeysPrepareResult(res, newsize);
782 }
783
784 res->keys[res->numkeys++] = pos;
785}
786
787/* Helper for RM_CreateCommand(). Turns a string representing command
788 * flags into the command flags used by the Redis core.

Callers

nothing calls this directly

Calls 1

getKeysPrepareResultFunction · 0.85

Tested by

no test coverage detected