Unverified Commit 25d827d9 authored by Eduardo Felipe's avatar Eduardo Felipe Committed by GitHub
Browse files

Add documentation for `firstkey`, `lastkey` and `keystep` parameters of...


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: default avatarEduardo Felipe Castegnaro <edufelipe@onsign.tv>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
parent e5a89282
...@@ -818,7 +818,7 @@ int64_t commandFlagsFromString(char *s) { ...@@ -818,7 +818,7 @@ int64_t commandFlagsFromString(char *s) {
} }
/* Register a new command in the Redis server, that will be handled by /* 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 * convention. The function returns REDISMODULE_ERR if the specified command
* name is already busy or a set of invalid flags were passed, otherwise * name is already busy or a set of invalid flags were passed, otherwise
* REDISMODULE_OK is returned and the new command is registered. * REDISMODULE_OK is returned and the new command is registered.
...@@ -876,6 +876,21 @@ int64_t commandFlagsFromString(char *s) { ...@@ -876,6 +876,21 @@ int64_t commandFlagsFromString(char *s) {
* to authenticate a client. * to authenticate a client.
* * **"may-replicate"**: This command may generate replication traffic, even * * **"may-replicate"**: This command may generate replication traffic, even
* though it's not a write command. * 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) { 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; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment