COMMAND INFO
Introduction
The COMMAND INFO
command is used to retrieve detailed information about one or more specified commands in the DiceDB server. For each command, it returns an array containing the command’s name, arity (number of arguments), command flags, and key-related information.
Syntax
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
command-name | The name of the command for which information is requested. | String | No |
Return Values
Condition | Return Value |
---|---|
Command is successful | Array containing detailed information about the specified commands. |
Error | An error is returned if the command fails. |
The detailed information for each command includes the following fields:
- Command Name: The name of the command.
- Arity: An integer representing the number of arguments the command expects.
- A positive number indicates the exact number of arguments.
- A negative number indicates that the command accepts a variable number of arguments.
- Flags (Note: Not supported currently) : An array of flags that describe the command’s properties (e.g.,
readonly
,fast
). - First Key: The position of the first key in the argument list (0-based index).
- Last Key: The position of the last key in the argument list.
- Key Step: The step between keys in the argument list, useful for commands with multiple keys.
The structure of the returned data is as follows:
Behavior
The COMMAND INFO
command retrieves detailed information about one or more specified commands in the DiceDB server. The command operates as follows:
- Input Arguments: The command takes a variable number of arguments, where each argument is expected to be the name of a command for which information is requested.
- Default Behavior: If no command names are provided, the command will return default information about all available commands.
- Command Metadata Retrieval: The command iterates over the predefined command metadata (
DiceCmds
) and stores the metadata in a map for quick lookup. - Command Name Lookup: For each provided command name, the command checks if it exists in the metadata map:
- If the command exists, its metadata is appended to the result list.
- If the command name is incorrect or not supported
nil
is appended in its place to indicate the absence of valid information.
- Result Encoding: Finally, the result list, which contains the metadata for the valid command names and
nil
for any invalid ones, is encoded and returned as the output.
Errors
Arity Error
- Error Message:
(error) ERR wrong number of arguments for 'command|info' command
- Occurs when an incorrect number of arguments is provided to the
COMMAND INFO
command.
- Error Message:
Example Usage
Get command info for SET
and MGET
Usage Example when mixture of valid and invalid commands
In this example, we request information for two commands: one valid (SET
) and one invalid (UNKNOWNCOMMAND
).
Incorrect Usage
An error is thrown when the command name passed to the COMMAND INFO
command is incorrect or not supported in DiceDB.
Note:
- If a valid command name is specified, its corresponding metadata is returned.
- If a command name is incorrect or not supported,
nil
is returned in its place.