From 25d827d949b2388bbdf459ba1b3ff0cb12ac6af6 Mon Sep 17 00:00:00 2001 From: Eduardo Felipe Date: Tue, 18 May 2021 11:19:30 -0300 Subject: [PATCH] Add documentation for `firstkey`, `lastkey` and `keystep` parameters of `RedisModule_CreateCommand` (#8883) These parameters of RedisModule_CreateCommand were previously undocumented but they are needed for ACL to check permission on keys and by Redis Cluster to figure our how to route the command. Co-authored-by: Eduardo Felipe Castegnaro Co-authored-by: Oran Agra --- src/module.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/module.c b/src/module.c index 813be1833c..b3939316e9 100644 --- a/src/module.c +++ b/src/module.c @@ -818,7 +818,7 @@ int64_t commandFlagsFromString(char *s) { } /* Register a new command in the Redis server, that will be handled by - * calling the function pointer 'func' using the RedisModule calling + * calling the function pointer 'cmdfunc' using the RedisModule calling * convention. The function returns REDISMODULE_ERR if the specified command * name is already busy or a set of invalid flags were passed, otherwise * REDISMODULE_OK is returned and the new command is registered. @@ -876,6 +876,21 @@ int64_t commandFlagsFromString(char *s) { * to authenticate a client. * * **"may-replicate"**: This command may generate replication traffic, even * though it's not a write command. + * + * The last three parameters specify which arguments of the new command are + * Redis keys. See https://redis.io/commands/command for more information. + * + * * 'firstkey': One-based index of the first argument that's a key. + * Position 0 is always the command name itself. + * 0 for commands with no keys. + * * 'lastkey': One-based index of the last argument that's a key. + * Negative numbers refer to counting backwards from the last + * argument (-1 means the last argument provided) + * 0 for commands with no keys. + * * 'keystep': Step between first and last key indexes. + * 0 for commands with no keys. + * + * This information is used by ACL, Cluster and the 'COMMAND' command. */ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0;