The TYPE command in DiceDB is used to determine the data type of the value stored at a specified key. This command is useful when you need to verify the type of data associated with a key before performing operations on it. It aids in debugging and helps ensure that the correct commands are used for different data types.
Syntax
Terminal window
TYPEkey
Parameters
Parameter
Description
Type
Required
key
The key to check for its value type
String
Yes
Return values
Condition
Return Value
Key exists
The type of the value stored at the key (string, list, set, zset, hash, stream)
Key does not exist
”none”
Behaviour
The TYPE command examines the value stored at the specified key and returns its data type.
If the key does not exist, the command returns “none”.
The command does not modify the value or the key in any way; it’s a read-only operation.
The time complexity of this command is O(1), making it efficient for frequent use.
Errors
Wrong number of arguments:
Error Message: (error) ERR wrong number of arguments for 'type' command
Occurs when the TYPE command is called without specifying a key or more than 1 arguement.