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

Function RM_KeyAtPos

src/module.cpp:798–811  ·  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

796 * keys are at fixed positions. This interface is only used for commands
797 * with a more complex structure. */
798void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) {
799 if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return;
800 if (pos <= 0) return;
801
802 getKeysResult *res = ctx->keys_result;
803
804 /* Check overflow */
805 if (res->numkeys == res->size) {
806 int newsize = res->size + (res->size > 8192 ? 8192 : res->size);
807 getKeysPrepareResult(res, newsize);
808 }
809
810 res->keys[res->numkeys++] = pos;
811}
812
813/* Helper for RM_CreateCommand(). Turns a string representing command
814 * 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