Serialize for RESTORE
Move or recreate a value
Redis · Module
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.
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.
DUMP key| Name | Type | Description |
|---|---|---|
key | key | The name of the key to serialize. |
Bulk string reply containing the serialized value, or a nil reply when the key does not exist.
SET mykey 10
DUMP mykeyStores a value, then returns its Redis-specific serialized representation.
Move or recreate a value
Inspect or transfer a Redis value in its native representation
Preserve a key’s expiration during migration
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.
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.
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.
RESTOREPTTLRDB