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)) { *
| 796 | * keys are at fixed positions. This interface is only used for commands |
| 797 | * with a more complex structure. */ |
| 798 | void 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. |
nothing calls this directly
no test coverage detected