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

Redis · Module

DUMP

Returns a Redis-specific serialized representation of the value stored at a key. The result can be used with RESTORE, but does not include expiration information.

Since
Redis Open Source 2.6.0

How it works

DUMP serializes the value held by a key into Redis’s opaque internal format. The resulting bytes can later be supplied to RESTORE, but expiration metadata is not included, so retrieve the remaining lifetime separately with PTTL when needed.

Syntax

DUMP key

Parameters

NameTypeDescription
keykeyThe name of the key to serialize.

Returns

Bulk string reply containing the serialized value, or a nil reply when the key does not exist.

Key points

  • DUMP converts the value associated with a key into Redis’s own serialized representation.
  • The serialized result is intended to be consumed by RESTORE to recreate a key.
  • A 64-bit checksum helps detect corruption in the serialized payload.
  • The value encoding follows the format Redis uses for RDB persistence data.
  • Each payload records an RDB version, allowing compatibility checks during restoration.
  • Access is constant-time, while serialization cost grows with the objects and their average size.

Common mistakes

  • Expiration is omitted from the serialized bytes; use PTTL separately if the key’s remaining lifetime must be preserved.
  • Serialized data may not be portable across Redis versions that use incompatible RDB formats.
  • A missing key produces a nil reply rather than serialized data.

Example: Serialize a value

SET mykey 10
DUMP mykey

Stores a value, then returns its Redis-specific serialized representation.

When to use it

Serialize for RESTORE

Move or recreate a value

Portable value handling

Inspect or transfer a Redis value in its native representation

Pair with PTTL

Preserve a key’s expiration during migration

Interview questions

QWhat does DUMP do, and how is its result used?

DUMP returns a Redis-specific serialized representation of the value at a key. RESTORE can use that representation to create a Redis key again.

Follow-up: What metadata is not preserved by DUMP? Expiration is excluded, so capture the remaining TTL with PTTL and restore it separately.

QWhat does DUMP return for existing and missing keys?

The command returns a bulk string containing serialized data when the key exists. If the key is absent, it returns a nil reply.

Follow-up: How should a client distinguish an absent key from an empty serialized payload? Check the protocol-level nil/null response rather than only testing byte-string length.

QWhat properties does the serialized format have?

The payload includes a checksum for error detection, uses RDB-style value encoding, and embeds an RDB version. RESTORE validates the checksum before reconstructing the key.

Follow-up: Why can interoperability fail between Redis versions? A version with an incompatible RDB format may refuse the payload.

  • RESTORE
  • PTTL
  • RDB

Source: DUMP. Checked 2026-10-16.