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
| 747 | * the context in a way that the command can recognize this is a special |
| 748 | * "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */ |
| 749 | int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 750 | RedisModuleCommandProxy *cp = (RedisModuleCommandProxy*)(unsigned long)cmd->getkeys_proc; |
| 751 | RedisModuleCtx ctx = REDISMODULE_CTX_INIT; |
| 752 | |
| 753 | ctx.module = cp->module; |
| 754 | ctx.client = NULL; |
| 755 | ctx.flags |= REDISMODULE_CTX_KEYS_POS_REQUEST; |
| 756 | |
| 757 | /* Initialize getKeysResult */ |
| 758 | getKeysPrepareResult(result, MAX_KEYS_BUFFER); |
| 759 | ctx.keys_result = result; |
| 760 | |
| 761 | cp->func(&ctx,(void**)argv,argc); |
| 762 | /* We currently always use the array allocated by RM_KeyAtPos() and don't try |
| 763 | * to optimize for the pre-allocated buffer. |
| 764 | */ |
| 765 | moduleFreeContext(&ctx); |
| 766 | return result->numkeys; |
| 767 | } |
| 768 | |
| 769 | /* -------------------------------------------------------------------------- |
| 770 | * ## Commands API |
no test coverage detected