COMMAND GETKEYS
Introduction
The COMMAND GETKEYS
command is used to extract the keys from a given command and its arguments in DiceDB. This command is particularly useful for analyzing the keys involved in a multi-key operation, such as MSET or DEL.
Syntax
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
command | The command for which keys need to be extracted. | String | Yes |
arg | Arguments for the specified command. | String | Yes |
Return values
Condition | Return Value |
---|---|
Command is successful | Array of keys |
Error | An error is returned if the command fails. |
Behavior
The COMMAND GETKEYS
command parses the provided command and its arguments to extract the keys that are involved. It ensures that the correct keys are identified, regardless of the specific operation being performed. Internally, DiceDB understands the structure of each command using keyspecs and identifies which parameters are keys.
Errors
-
Arity Error for COMMAND GETKEYS
- Error Message:
(error) ERR wrong number of arguments for 'command|getkeys' command
- Occurs when an incorrect number of arguments is provided for the
COMMAND GETKEYS
command.
- Error Message:
-
Arity Error for command
- Error Message:
(error) ERR invalid number of arguments specified for command
- Occurs when invalid number of arguments provided for command.
- Error Message:
-
Invalid command specified
- Error Message:
(error) ERR invalid command specified
- Occurs when the provided command is not a recognized DiceDB command.
- Error Message:
-
No keys arguments
- Error Message:
(error) ERR the command has no key arguments
- Occurs when the provided command does not accept any key arguments (ex.
FLUSHDB
).
- Error Message:
Example Usage
Extracting keys from MSET command
Extracting keys from DEL command
Error: Arity Error for COMMAND GETKEYS
An arity error is thrown when the incorrect number of arguments is provided to the COMMAND GETKEYS
command.
Error: Arity Error for command name passed to COMMAND GETKEYS
An arity error is thrown when the incorrect number of arguments is provided to the command passed to COMMAND GETKEYS
command.
Error: Command Not Supported
An error is thrown when the specified command is not supported or recognized by the DiceDB server.
Error: Command Does Not Accept Key Arguments
An error is thrown when attempting to retrieve keys for a command that does not accept any key arguments.