Add documentation for `firstkey`, `lastkey` and `keystep` parameters of `RedisModule_CreateCommand`
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.
@@ -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;
