Skip to content

TYPE

Get the type of value stored at key.

Terminal window
TYPE key

Parameter Description

  • key: The key to query type

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.

Returns the type string of the value stored at key:

  • string: String type
  • list: List type
  • set: Set type
  • zset: Sorted set type
  • hash: Hash type
  • none: Key does not exist

O(1)

// Synchronous mode
String type = redisun.type("mykey");
// Asynchronous mode
CompletableFuture<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