w3resource

Redis Keys: DUMP

Redis DUMP Command

Redis DUMP command is used to serialize the value stored at key in a Redis-specific format and return it to the user. The returned value can be synthesized back into a Redis key using the RESTORE command.

The serialization format is opaque and non-standard, however, it has a few semantic characteristics:

  • It contains a 64-bit checksum that is used to make sure errors will be detected. The RESTORE command makes sure to check the checksum before synthesizing a key using the serialized value.
  • Values are encoded in the same format used by RDB.
  • An RDB version is encoded inside the serialized value so that different Redis versions with incompatible RDB formats will refuse to process 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 the key does not exist a nil bulk reply is returned.

Here are some common uses and scenarios for the "DUMP" command:

  • Backup: Create a binary dump of a key's value for backup purposes.
  • Data Transfer: Export data to be imported into another Redis instance.
  • Migration: Move data between Redis servers or environments.
  • Snapshotting: Capture the state of a key for later restoration.

Syntax:

DUMP KEY_NAME

Available since

2.6.0.

Return Value

Bulk string reply: the serialized value.

Return Value Type

String

Example: Redis DUMP

First, create a key in redis and set some value in it.

127.0.0.1:6379> SET key1 Good
OK
127.0.0.1:6379> DUMP key1
"\x00\x04Good\x06\x00\x94O\x0e\x8d\xb3\x0b\x00?"

Previous: DEL
Next: EXISTS



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/redis/redis-dump-key.php