Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redis · Module

TYPE

TYPE reports the Redis data type stored at a key. It returns none when the key does not exist.

How it works

TYPE examines the value associated with one key and returns its Redis data-type name. If the key is absent, it returns none; otherwise the documented result can identify strings, lists, sets, sorted sets, hashes, streams, or vector sets.

Syntax

TYPE key

Parameters

NameTypeDescription
keykeyThe name of the key whose value type should be returned.

Returns

Simple string reply: the type of key, or none when key does not exist.

Key points

  • TYPE converts the stored value's data structure into a type-name string.
  • Recognized results include string, list, set, and sorted set values.
  • The command also recognizes hashes, streams, and vector sets.
  • Its required input is the key name to inspect.
  • The response is a simple string containing the type, or none when the key is missing.

Common mistakes

  • An absent key produces none rather than an error, so callers should handle that result separately from a stored type.

Example: Inspect Redis value types

redis-cli <<'EOF'
SET profile:name Ada
HSET profile:stats visits 3
TYPE profile:name
TYPE profile:stats
TYPE profile:missing
EOF

Creates a string and a hash, then reports each stored value's Redis type or none for the absent key.

When to use it

Validate a data structure

Inspect a key before issuing type-specific commands.

Debug key contents

Diagnose unexpected values in a shared keyspace.

Check cache state

Distinguish missing cache entries from populated entries.

Interview questions

QWhat does TYPE return for a missing key?

TYPE takes one key and returns a simple string naming the stored value's type. If the key does not exist, the result is none.

Follow-up: How would you distinguish an absent key from a key holding a string? Check whether TYPE returns none; string indicates an existing string value.

QWhat is the syntax and required argument?

The command syntax is TYPE key. The required key argument is the name of the key whose value should be inspected.

Follow-up: What should be done when the key name is dynamic? Pass the key as a properly encoded command argument and interpret the returned type string.

QWhich Redis types can TYPE report?

TYPE can report string, list, set, zset, hash, stream, or vectorset. It is useful before selecting commands that operate on a particular Redis data structure.

Follow-up: Why must command selection still be validated after inspection? The key's type can change between separate commands, so atomic or error-handling strategies may be needed.

  • EXISTS
  • SCAN
  • DEL
  • JSON.TYPE

Source: Type | Docs - Redis. Checked 2026-10-16.