This function returns the list of keys, with the same interface as the * 'getkeys' function of the native commands, for module commands that exported * the "getkeys-api" flag during the registration. This is done when the * list of keys are not at fixed positions, so that first/last/step cannot * be used. * * In order to accomplish its work, the module command is called, flagging * the cont
| 721 | * the context in a way that the command can recognize this is a special |
| 722 | * "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */ |
| 723 | int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 724 | RedisModuleCommandProxy *cp = (void*)(unsigned long)cmd->getkeys_proc; |
| 725 | RedisModuleCtx ctx = REDISMODULE_CTX_INIT; |
| 726 | |
| 727 | ctx.module = cp->module; |
| 728 | ctx.client = NULL; |
| 729 | ctx.flags |= REDISMODULE_CTX_KEYS_POS_REQUEST; |
| 730 | |
| 731 | /* Initialize getKeysResult */ |
| 732 | getKeysPrepareResult(result, MAX_KEYS_BUFFER); |
| 733 | ctx.keys_result = result; |
| 734 | |
| 735 | cp->func(&ctx,(void**)argv,argc); |
| 736 | /* We currently always use the array allocated by RM_KeyAtPos() and don't try |
| 737 | * to optimize for the pre-allocated buffer. |
| 738 | */ |
| 739 | moduleFreeContext(&ctx); |
| 740 | return result->numkeys; |
| 741 | } |
| 742 | |
| 743 | /* -------------------------------------------------------------------------- |
| 744 | * ## Commands API |
no test coverage detected