Returns a serialized representation of the value stored at a key.
DUMP
key
Serialize the value stored at key in a Valkey-specific format and
return it to the user. The returned value can be synthesized back into a
Valkey key using the RESTORE
command.
The serialization format is opaque and non-standard, however it has a few semantic characteristics:
RESTORE
command makes sure to check the
checksum before synthesizing a key using the serialized value.The serialized value does NOT contain expire information. In order to
capture the time to live of the current value the PTTL
command should be used.
If key
does not exist a nil bulk reply is returned.
One of the following:
Bulk string reply: The serialized value of the key.
Nil reply: the key does not exist.
One of the following:
Bulk string reply: the serialized value of the key.
Null reply: the key does not exist.
O(1) to access the key and additional O(NM) to serialize it, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1M) where M is small, so simply O(1).
@keyspace @read @slow
> SET mykey 10
OK
> DUMP mykey
"\x00\xc0\n\n\x00n\x9fWE\x0e\xaec\xbb"
COPY, DEL, EXISTS, EXPIRE, EXPIREAT, EXPIRETIME, KEYS, MIGRATE, MOVE, OBJECT, OBJECT ENCODING, OBJECT FREQ, OBJECT HELP, OBJECT IDLETIME, OBJECT REFCOUNT, PERSIST, PEXPIRE, PEXPIREAT, PEXPIRETIME, PTTL, RANDOMKEY, RENAME, RENAMENX, RESTORE, SCAN, SORT, SORT_RO, TOUCH, TTL, TYPE, UNLINK, WAIT, WAITAOF.