COMMAND
The COMMAND
command in DiceDB is a powerful introspection tool that provides detailed information about all the DiceDB commands supported by the server. This command can be used to retrieve metadata about commands, such as their arity, flags, first key, last key, and key step. It is particularly useful for clients and developers who need to understand the capabilities and constraints of the DiceDB commands available in their environment.
The COMMAND
command can be used in multiple forms, supporting various subcommands, each with its own set of parameters. However, the default implementation, which does not require any subcommand, is as follows.
Syntax
Parameters
This command does not accept any parameters.
Return values
Condition | Return Value |
---|---|
Command is successful | Array containing detailed information about all commands supported by the DiceDB server. |
Error | An error is returned if the command fails. |
- 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.
Behavior
When no subcommand is provided, this command functions as the default implementation of the COMMAND INFO
command in the absence of a specified command name. It iterates through the list of registered commands and subcommands, returning an array containing detailed metadata for each command.
Errors
No error is thrown in the default implementation of the COMMAND
command when no subcommand is provided.
Example Usage
Retrieve Detailed Information for Each Command Supported by the DiceDB Server
Subcommands
Syntax
Parameters
- subcommand: Optional. Available subcommands include:
COUNT
: Returns the total number of commands in the DiceDB server.GETKEYS
: Returns the keys from the provided command and arguments.LIST
: Returns the list of all the commands in the DiceDB server.INFO
: Returns details about the specified commands.HELP
: Displays the help section forCOMMAND
, providing information about each available subcommand.
For more details on each subcommand, please refer to their respective documentation pages.
Errors
Unknown subcommand
- Error Message:
(error) ERR unknown subcommand 'sucommand-name'. Try COMMAND HELP.
- This error may occur if the subcommand is misspelled or not recognized by the DiceDB server.
- Error Message:
Example Usage
Invalid usage
An error is thrown when an incorrect or unsupported subcommand name is provided.