content/commands/command.md
Return an array with details about every Redis command.
The COMMAND command is introspective.
Its reply describes all commands that the server can process.
Redis clients can call it to obtain the server's runtime capabilities during the handshake.
COMMAND also has several subcommands.
Please refer to its subcommands for further details.
Cluster note:
this command is especially beneficial for cluster-aware clients.
Such clients must identify the names of keys in commands to route requests to the correct shard.
Although most commands accept a single key as their first argument, there are many exceptions to this rule.
You can call COMMAND and then keep the mapping between commands and their respective key specification rules cached in the client.
The reply it returns is an array with an element per command. Each element that describes a Redis command is represented as an array by itself.
The command's array consists of a fixed number of elements. The exact number of elements in the array depends on the server's version.
This is the command's name in lowercase.
Note: Redis command names are case-insensitive.
Arity is the number of arguments a command expects. It follows a simple pattern:
Command arity always includes the command's name itself (and the subcommand when applicable).
Examples:
GET]({{< relref "/commands/get" >}})'s arity is 2 since the command only accepts one argument and always has the format GET _key_.MGET]({{< relref "/commands/mget" >}})'s arity is -2 since the command accepts at least one argument, but possibly multiple ones: MGET _key1_ [key2] [key3] ....Command flags are an array. It can contain the following simple strings (status reply):
LATENCY]({{< relref "/commands/latency" >}}) command.COMMAND GETKEYS]({{< relref "/commands/command-getkeys" >}}) or key specifications in this case.
See below for more details.SWAPDB SYNC, and allows access to the old dataset).MONITOR]({{< relref "/commands/monitor" >}})'s output.SLOWLOG]({{< relref "/commands/slowlog" >}})'s output.
As of Redis 7.0, this flag is a command tip.Consider [SORT]({{< relref "/commands/sort" >}}):
1) 1) "sort"
2) (integer) -2
3) 1) write
2) denyoom
3) movablekeys
4) (integer) 1
5) (integer) 1
6) (integer) 1
...
Some Redis commands have no predetermined key locations or are not easy to find. For those commands, the movablekeys flag indicates that the first key, last key, and step values are insufficient to find all the keys.
Here are several examples of commands that have the movablekeys flag:
SORT]({{< relref "/commands/sort" >}}): the optional STORE, BY, and GET modifiers are followed by names of keys.ZUNION]({{< relref "/commands/zunion" >}}): the numkeys argument specifies the number key name arguments.MIGRATE]({{< relref "/commands/migrate" >}}): the keys appear KEYS keyword and only when the second argument is the empty string.Redis Cluster clients need to use other measures, as follows, to locate the keys for such commands.
You can use the [COMMAND GETKEYS]({{< relref "/commands/command-getkeys" >}}) command and have your Redis server report all keys of a given command's invocation.
As of Redis 7.0, clients can use the key specifications to identify the positions of key names.
The only commands that require using [COMMAND GETKEYS]({{< relref "/commands/command-getkeys" >}}) are [SORT]({{< relref "/commands/sort" >}}) and [MIGRATE]({{< relref "/commands/migrate" >}}) for clients that parse keys' specifications.
For more information, please refer to the key specifications page.
The position of the command's first key name argument. For most commands, the first key's position is 1. Position 0 is always the command name itself.
The position of the command's last key name argument. Redis commands usually accept one, two or multiple number of keys.
Commands that accept a single key have both first key and last key set to 1.
Commands that accept two key name arguments, e.g. [BRPOPLPUSH]({{< relref "/commands/brpoplpush" >}}), [SMOVE]({{< relref "/commands/smove" >}}) and [RENAME]({{< relref "/commands/rename" >}}), have this value set to the position of their second key.
Multi-key commands that accept an arbitrary number of keys, such as [MSET]({{< relref "/commands/mset" >}}), use the value -1.
The step, or increment, between the first key and the position of the next key.
Consider the following two examples:
1) 1) "mset"
2) (integer) -3
3) 1) write
2) denyoom
4) (integer) 1
5) (integer) -1
6) (integer) 2
...
1) 1) "mget"
2) (integer) -2
3) 1) readonly
2) fast
4) (integer) 1
5) (integer) -1
6) (integer) 1
...
The step count allows us to find keys' positions.
For example [MSET]({{< relref "/commands/mset" >}}): Its syntax is MSET _key1_ _val1_ [key2] [val2] [key3] [val3]..., so the keys are at every other position (step value of 2).
Unlike [MGET]({{< relref "/commands/mget" >}}), which uses a step value of 1.
This is an array of simple strings that are the ACL categories to which the command belongs. Please refer to the Access Control List page for more information.
Helpful information about the command. To be used by clients/proxies.
Please check the Command tips page for more information.
This is an array consisting of the command's key specifications. Each element in the array is a map describing a method for locating keys in the command's arguments.
For more information please check the key specifications page.
This is an array containing all of the command's subcommands, if any.
Some Redis commands have subcommands (e.g., the REWRITE subcommand of [CONFIG]({{< relref "/commands/config" >}})).
Each element in the array represents one subcommand and follows the same specifications as those of COMMAND's reply.
The following is COMMAND's output for the [GET]({{< relref "/commands/get" >}}) command:
1) 1) "get"
2) (integer) 2
3) 1) readonly
2) fast
4) (integer) 1
5) (integer) 1
6) (integer) 1
7) 1) @read
2) @string
3) @fast
8) (empty array)
9) 1) 1) "flags"
2) 1) read
3) "begin_search"
4) 1) "type"
2) "index"
3) "spec"
4) 1) "index"
2) (integer) 1
5) "find_keys"
6) 1) "type"
2) "range"
3) "spec"
4) 1) "lastkey"
2) (integer) 0
3) "keystep"
4) (integer) 1
5) "limit"
6) (integer) 0
10) (empty array)
...
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |
{{< multitabs id="command-return-info" tab1="RESP2" tab2="RESP3" >}}
Array reply: a nested list of command details. The order of the commands in the array is random.
-tab-sep-
Array reply: a nested list of command details. The order of the commands in the array is random.
{{< /multitabs >}}