type
TYPE
Return the data type of a key
Usage: type key.
data type : string, list, set, zset, hash, stream
Example
| Command> | set mystr value string |
| Result> | OK |
| Command> | type mystr |
| Result> | string |
| Command> | lpush mylist value list |
| Result> | 1 |
| Command> | type mylist |
| Result> | list |
| Command> | sadd myset value set |
| Result> | 1 |
| Command> | type myset |
| Result> | set |
| Command> | zadd myzset value zset(Sorted Set) |
| Result> | 1 |
| Command> | type myzset |
| Result> | zset |
| Command> | hset myhash 0 value hash |
| Result> | 1 |
| Command> | type myhash |
| Result> | hash |
Syntax
TYPE key
- Available since version 1.0.0.
- Time complexity is O(1).