TYPE
Get the type of value stored at key.
Redis Native Command Syntax
Section titled “Redis Native Command Syntax”TYPE keyParameter Description
- key: The key to query type
Detailed Explanation
Section titled “Detailed Explanation”The TYPE command returns the type of value stored at key. Redis supports multiple data types, including string, list, set, sorted set (zset), hash, etc.
Return Value
Section titled “Return Value”Returns the type string of the value stored at key:
string: String typelist: List typeset: Set typezset: Sorted set typehash: Hash typenone: Key does not exist
Time Complexity
Section titled “Time Complexity”O(1)
Redisun Usage
Section titled “Redisun Usage”// Synchronous modeString type = redisun.type("mykey");
// Asynchronous modeCompletableFuture<String> future = redisun.asyncType("mykey");Notes
- The TYPE command only returns the type of value stored at key, not the value itself
- For non-existent keys, the TYPE command returns “none”
References