In Redis, the TYPE command returns a key’s type. More specifically, it returns the string representation of the type of the value stored at a given key.
Syntax
TYPE key
Where key is the key in question.
Example
Here’s an example to demonstrate:
TYPE firstname
Result:
string
Here, the firstname key holds a string.
Let’s try another key:
TYPE pets
Result:
list
In this case the pets key holds a list.
The different types that can be returned are: string, list, set, zset, hash and stream. Note that these are different to the internal encodings returned by the OBJECT ENCODING command.