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