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 <edufelipe@onsign.tv>
Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
Eduardo Felipe 2021-05-18 11:19:30 -03:00 committed by GitHub
parent e5a8928290
commit 25d827d949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;