Redis Command: DUMP

Summary

Command NameDUMP
UsageGet serialized value of a key
Group generic
ACL Category@keyspace
@read
@slow
Time ComplexityO(1) + O(N * M)
FlagREADONLY
Arity2

NOTES

  • O(1) is the complexity of accessing the key.
  • O(N * M) is the complexity of serializing the value
    • N is the number of Redis objects that the value is composed of.
    • M is the average size of the values.
  • In the case of an average-size string value, N=1, so the complexity will be O(1) + O(1 * M). If M is a small value, then the complexity will be O(1).

Signature

DUMP <key>

NOTES

  • This command will not fail in any case. It will always return some value, or will return null(nil) in case of a non-existing key.

Usage

Serialize the value of a key, in a specific format.

64-bit checksum is used, so that the RESTORE command can check the integrity of the data while restoring.

This command is very useful when we want to recreate or copy some value like a big list or set or hash etc, on the Redis server.

NOTES

  • We can use the serialize value to later recreate/restore the value. Redis command RESTORE can be used for the restoration.
  • The encoding format is the same as the format used for the RDB file. RDB version is also added to the encoded value.
  • If the key has an expiration time, then that expiration time is not stored in the encoded value.

Arguments

ParameterDescriptionNameType
<key>key name of the itemkeykey

Return Value

Return valueCase for the return valueType
encoded valueEncode value of the stored valuestring
(nil)If the key does not existnull

In the encoded value we have RDB formatted value of the original stored value, then 2 bytes of RDB version, and then 8 bytes of CRC64.

NOTES

  • If we provide a non-existing key, then the command returns a null value(nil).

Command Examples

Here are a few examples of the DUMP command usage-

# Redis DUMP command examples

# Set a string value
127.0.0.1:6379> set bigboxstr "My string value saved in a Big Box"
OK

# Check string value
127.0.0.1:6379> get bigboxstr
"My string value saved in a Big Box"

# DUMP string
127.0.0.1:6379> dump bigboxstr
"\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"


# Add items to list
127.0.0.1:6379> rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
(integer) 7

# Check list items
127.0.0.1:6379> lrange bigboxlist 0 -1
1) "abc123"
2) "def234"
3) "ghi345"
4) "jkl456"
5) "mno567"
6) "pqrst678"
7) "uvwxyz789"

# DUMP list data
127.0.0.1:6379> dump bigboxlist
"\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"


# Add items to set
127.0.0.1:6379> sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
(integer) 5

# Check set items
127.0.0.1:6379> smembers bigboxset
1) "1619751279"
2) "6218014406"
3) "7595030997"
4) "7858399611"
5) "9982317472"

# DUMP set data
127.0.0.1:6379> dump bigboxset
"\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"


# Add item to hash
127.0.0.1:6379> hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
(integer) 7

# Check hash data
127.0.0.1:6379> hgetall bigboxhash
 1) "secret1"
 2) "3622625569"
 3) "secret2"
 4) "5251979648"
 5) "secret3"
 6) "7686908197"
 7) "secret4"
 8) "0645904521"
 9) "secret5"
10) "8386817336"
11) "secret6"
12) "2706180686"
13) "secret7"
14) "7252297879"

# DUMP hash data
127.0.0.1:6379> dump bigboxhash
"\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"


# Add item to sorted set
127.0.0.1:6379> zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
(integer) 5

# Check sorted set data
127.0.0.1:6379> zrange bigboxsortedset 0 -1
1) "GM0F1JGPMJ"
2) "0X2ZET2CP4"
3) "4NBR9A4FMF"
4) "LD4X0F70OC"
5) "U2M07EJDSB"

# DUMP sorted set data
127.0.0.1:6379> dump bigboxsortedset
"\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"


# Try to dump a non existing key
# We get null
127.0.0.1:6379> dump nonexistingkey
(nil)

NOTES

  • We can use the dumped value, with REPLACE command to set the value.

Code Implementations

Here are the usage examples of the Redis DUMP command in different programming languages.

// Redis DUMP command example in Golang

package main

import (
	"context"
	"fmt"

	"github.com/redis/go-redis/v9"
)

var rdb *redis.Client
var ctx context.Context

func init() {
	rdb = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Username: "default",
		Password: "",
		DB:       0,
	})

	ctx = context.Background()
}

func main() {

	/**
	* Set a string value
	*
	* Command: set bigboxstr "My string value saved in a Big Box"
	* Result: OK
	 */
	setResult, err := rdb.Set(ctx, "bigboxstr", "My string value saved in a Big Box", 0).Result()

	if err != nil {
		fmt.Println("Command: set bigboxstr \"My string value saved in a Big Box\" | Error: " + err.Error())

	}

	fmt.Println("Command: set bigboxstr \"My string value saved in a Big Box\" | Result: " + setResult)

	/**
	* Check string value
	*
	* Command: get bigboxstr
	* Result: "My string value saved in a Big Box"
	 */
	getResult, err := rdb.Get(ctx, "bigboxstr").Result()

	if err != nil {
		fmt.Println("Command: get bigboxstr | Error: " + err.Error())

	}

	fmt.Println("Command: get bigboxstr | Result" + getResult)

	/**
	* DUMP string
	*
	* Command: dump bigboxstr
	* Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
	 */
	dumpResult, err := rdb.Dump(ctx, "bigboxstr").Result()

	if err != nil {
		fmt.Println("Command: dump bigboxstr | Error: " + err.Error())

	}

	fmt.Println("Command: dump bigboxstr | Result: ", dumpResult)

	/**
	* Add items to list
	*
	* Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
	* Result: (integer) 7
	 */
	rpushResult, err := rdb.RPush(ctx, "bigboxlist", "abc123", "def234", "ghi345", "jkl456", "mno567", "pqrst678", "uvwxyz789").Result()

	if err != nil {
		fmt.Println("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Error: " + err.Error())
	}

	fmt.Println("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: ", rpushResult)

	/**
	* Check list items
	*
	* Command: lrange bigboxlist 0 -1
	* Result:
	*      1) "abc123"
	*      2) "def234"
	*      3) "ghi345"
	*      4) "jkl456"
	*      5) "mno567"
	*      6) "pqrst678"
	*      7) "uvwxyz789"
	 */
	lrangeResult, err := rdb.LRange(ctx, "bigboxlist", 0, -1).Result()

	if err != nil {
		fmt.Println("Command: lrange bigboxlist 0 -1 | Error: " + err.Error())
	}

	fmt.Println("Command: lrange bigboxlist 0 -1 | Result: ", lrangeResult)

	/**
	* DUMP list data
	*
	* Command: dump bigboxlist
	* Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
	 */
	dumpResult, err = rdb.Dump(ctx, "bigboxlist").Result()

	if err != nil {
		fmt.Println("Command: dump bigboxlist | Error: " + err.Error())
	}

	fmt.Println("Command: dump bigboxlist | Result: " + dumpResult)

	/**
	* Add items to set
	*
	* Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
	* Result: (integer) 5
	 */
	saddResult, err := rdb.SAdd(ctx, "bigboxset", "6218014406", "1619751279", "7858399611", "7595030997", "9982317472").Result()

	if err != nil {
		fmt.Println("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Error: " + err.Error())
	}

	fmt.Println("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: ", saddResult)

	/**
	* Check set items
	*
	* Command: smembers bigboxset
	* Result:
	*      1) "1619751279"
	*      2) "6218014406"
	*      3) "7595030997"
	*      4) "7858399611"
	*      5) "9982317472"
	 */
	smemebersResult, err := rdb.SMembers(ctx, "bigboxset").Result()

	if err != nil {
		fmt.Println("Command: smembers bigboxset | Error: " + err.Error())
	}

	fmt.Println("Command: smembers bigboxset | Result: ", smemebersResult)

	/**
	* DUMP set data
	*
	* Command: dump bigboxset
	* Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
	 */
	dumpResult, err = rdb.Dump(ctx, "bigboxset").Result()

	if err != nil {
		fmt.Println("Command: dump bigboxset | Error: " + err.Error())

	}

	fmt.Println("Command: dump bigboxset | Result: " + dumpResult)

	/**
	* Add item to hash
	*
	* Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
	* Result: (integer) 7
	 */
	hsetResult, err := rdb.HMSet(ctx, "bigboxhash",
		"secret1", "3622625569",
		"secret2", "5251979648",
		"secret3", "7686908197",
		"secret4", "0645904521",
		"secret5", "8386817336",
		"secret6", "2706180686",
		"secret7", "7252297879",
	).Result()

	if err != nil {
		fmt.Println("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Error: " + err.Error())
	}

	fmt.Println("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: ", hsetResult)

	/**
	* Check hash data
	*
	* Command: hgetall bigboxhash
	* Result:
	*      1) "secret1"
	*      2) "3622625569"
	*      3) "secret2"
	*      4) "5251979648"
	*      5) "secret3"
	*      6) "7686908197"
	*      7) "secret4"
	*      8) "0645904521"
	*      9) "secret5"
	*      10) "8386817336"
	*      11) "secret6"
	*      12) "2706180686"
	*      13) "secret7"
	*      14) "7252297879"
	 */
	hgetallResult, err := rdb.HGetAll(ctx, "bigboxhash").Result()

	if err != nil {
		fmt.Println("Command: hgetall bigboxhash | Error: " + err.Error())
	}

	fmt.Println("Command: hgetall bigboxhash | Result: ", hgetallResult)

	/**
	* DUMP hash data
	*
	* Command: dump bigboxhash
	* Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
	 */
	dumpResult, err = rdb.Dump(ctx, "bigboxhash").Result()

	if err != nil {
		fmt.Println("Command: dump bigboxhash | Error: " + err.Error())
	}

	fmt.Println("Command: dump bigboxhash | Result: " + dumpResult)

	/**
	* Add item to sorted set
	*
	* Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
	* Result: (integer) 5
	 */
	zaddResult, err := rdb.ZAdd(ctx, "bigboxsortedset",
		redis.Z{
			Score:  1,
			Member: "GM0F1JGPMJ",
		},
		redis.Z{
			Score:  5,
			Member: "U2M07EJDSB",
		},
		redis.Z{
			Score:  3,
			Member: "4NBR9A4FMF",
		},
		redis.Z{
			Score:  2,
			Member: "0X2ZET2CP4",
		},
		redis.Z{
			Score:  4,
			Member: "LD4X0F70OC",
		},
	).Result()

	if err != nil {
		fmt.Println("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Error: " + err.Error())
	}

	fmt.Println("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: ", zaddResult)

	/**
	* Check sorted set data
	*
	* Command: zrange bigboxsortedset 0 -1
	* Result:
	*      1) "GM0F1JGPMJ"
	*      2) "0X2ZET2CP4"
	*      3) "4NBR9A4FMF"
	*      4) "LD4X0F70OC"
	*      5) "U2M07EJDSB"
	 */
	zrangeResult, err := rdb.ZRange(ctx, "bigboxsortedset", 0, -1).Result()

	if err != nil {
		fmt.Println("Command: zrange bigboxsortedset 0 -1 | Error: " + err.Error())
	}

	fmt.Println("Command: zrange bigboxsortedset 0 -1 | Result: ", zrangeResult)

	/**
	* DUMP sorted set data
	*
	* Command: dump bigboxsortedset
	* Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
	 */
	dumpResult, err = rdb.Dump(ctx, "bigboxsortedset").Result()

	if err != nil {
		fmt.Println("Command: dump bigboxsortedset | Error: " + err.Error())
	}

	fmt.Println("Command: dump bigboxsortedset | Result: " + dumpResult)

	/**
	* Try to dump a non existing key
	* We get null
	*
	* Command: dump nonexistingkey
	* Result: (nil)
	 */
	dumpResult, err = rdb.Dump(ctx, "nonexistingkey").Result()

	if err != nil {
		fmt.Println("Command: dump nonexistingkey | Error: " + err.Error())
	}

	fmt.Println("Command: dump nonexistingkey | Result: " + dumpResult)

}

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: OK
Command: get bigboxstr | ResultMy string value saved in a Big Box
Command: dump bigboxstr | Result:  "My string value saved in a Big Box
�3
�M�!

Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result:  7
Command: lrange bigboxlist 0 -1 | Result:  [abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789]
Command: dump bigboxlist | Result: ↕☺☻@DD�abc123�def234�ghi345�jkl456�mno567�pqrst678   �uvwxyz789
�
 �∟'

Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result:  5
Command: smembers bigboxset | Result:  [1619751279 6218014406 7595030997 7858399611 9982317472]
Command: dump bigboxset | Result:
♣oq�`�^�r☺����☺{�e�☺�‼�R☻
�,�9‼�f�

Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result:  true
Command: hgetall bigboxhash | Result:  map[secret1:3622625569 secret2:5251979648 secret3:7686908197 secret4:0645904521 secret5:8386817336 secret6:2706180686 secret7:7252297879]
Command: dump bigboxhash | Result: ►�@i@�‼��secret�!��� ↕☺      �↕���
�0645904521�♥↕
�:♠�8����♥'♠�N
M� L�`♠��HE�@%☺ �
�§��K��R

Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result:  5
Command: zrange bigboxsortedset 0 -1 | Result:  [GM0F1JGPMJ 0X2ZET2CP4 4NBR9A4FMF LD4X0F70OC U2M07EJDSB]
Command: dump bigboxsortedset | Result: ◄@MM
�GM0F1JGPMJ
☺☺�0X2ZET2CP4
☻☺�4NBR9A4FMF
♥☺�LD4X0F70OC
♦☺�U2M07EJDSB
♣☺�
�
C↓�[�

Command: dump nonexistingkey | Error: redis: nil
Command: dump nonexistingkey | Result:

NOTES

  • Use “Dump” method from redis-go module.
  • Signature of the methods is-
    func (c cmdable) Dump(ctx context.Context, key string) *StringCmd
// Redis DUMP command example in JavaScript(NodeJS)

import { createClient } from "redis";

// Create redis client
const redisClient = createClient({
  url: "redis://default:@localhost:6379",
});

redisClient.on("error", (err) =>
  console.log("Error while connecting to Redis", err)
);

// Connect Redis client
await redisClient.connect();

/**
 * Set a string value
 *
 * Command: set bigboxstr "My string value saved in a Big Box"
 * Result: OK
 */
let commandResult = await redisClient.set(
  "bigboxstr",
  "My string value saved in a Big Box"
);

console.log(
  'Command: set bigboxstr "My string value saved in a Big Box" | Result: ' +
    commandResult
);

/**
 * Check string value
 *
 * Command: get bigboxstr
 * Result: "My string value saved in a Big Box"
 */
commandResult = await redisClient.get("bigboxstr");

console.log("Command: get bigboxstr | Result" + commandResult);

/**
 * DUMP string
 *
 * Command: dump bigboxstr
 * Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
 */
commandResult = await redisClient.dump("bigboxstr");

console.log("Command: dump bigboxstr | Result: " + commandResult);

/**
 * Add items to list
 *
 * Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
 * Result: (integer) 7
 */
commandResult = await redisClient.rPush(
  "bigboxlist",
  "abc123",
  "def234",
  "ghi345",
  "jkl456",
  "mno567",
  "pqrst678",
  "uvwxyz789"
);

console.log(
  "Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: " +
    commandResult
);

/**
 * Check list items
 *
 * Command: lrange bigboxlist 0 -1
 * Result:
 *      1) "abc123"
 *      2) "def234"
 *      3) "ghi345"
 *      4) "jkl456"
 *      5) "mno567"
 *      6) "pqrst678"
 *      7) "uvwxyz789"
 */
commandResult = await redisClient.lRange("bigboxlist", 0, -1);

console.log("Command: lrange bigboxlist 0 -1 | Result: ", commandResult);

/**
 * DUMP list data
 *
 * Command: dump bigboxlist
 * Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
 */
commandResult = await redisClient.dump("bigboxlist");

console.log("Command: dump bigboxlist | Result: " + commandResult);

/**
 * Add items to set
 *
 * Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
 * Result: (integer) 5
 */
commandResult = await redisClient.sAdd(
  "bigboxset",
  "6218014406",
  "1619751279",
  "7858399611",
  "7595030997",
  "9982317472"
);

console.log(
  "Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: " +
    commandResult
);

/**
 * Check set items
 *
 * Command: smembers bigboxset
 * Result:
 *      1) "1619751279"
 *      2) "6218014406"
 *      3) "7595030997"
 *      4) "7858399611"
 *      5) "9982317472"
 */
commandResult = await redisClient.sMembers("bigboxset");

console.log("Command: smembers bigboxset | Result: ", commandResult);

/**
 * DUMP set data
 *
 * Command: dump bigboxset
 * Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
 */
commandResult = await redisClient.dump("bigboxset");

console.log("Command: dump bigboxset | Result: " + commandResult);

/**
 * Add item to hash
 *
 * Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
 * Result: (integer) 7
 */
const hashData = [
  ["secret1", "3622625569"],
  ["secret2", "5251979648"],
  ["secret3", "7686908197"],
  ["secret4", "0645904521"],
  ["secret5", "8386817336"],
  ["secret6", "2706180686"],
  ["secret7", "7252297879"],
];
commandResult = await redisClient.hSet("bigboxhash", hashData);

console.log(
  "Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: " +
    commandResult
);

/**
 * Check hash data
 *
 * Command: hgetall bigboxhash
 * Result:
 *      1) "secret1"
 *      2) "3622625569"
 *      3) "secret2"
 *      4) "5251979648"
 *      5) "secret3"
 *      6) "7686908197"
 *      7) "secret4"
 *      8) "0645904521"
 *      9) "secret5"
 *      10) "8386817336"
 *      11) "secret6"
 *      12) "2706180686"
 *      13) "secret7"
 *      14) "7252297879"
 */
commandResult = await redisClient.hGetAll("bigboxhash");

console.log("Command: hgetall bigboxhash | Result: ", commandResult);

/**
 * DUMP hash data
 *
 * Command: dump bigboxhash
 * Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
 */
commandResult = await redisClient.dump("bigboxhash");

console.log("Command: dump bigboxhash | Result: " + commandResult);

/**
 * Add item to sorted set
 *
 * Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
 * Result: (integer) 5
 */
const ssData = [
  {
    score: 1,
    value: "GM0F1JGPMJ",
  },
  {
    score: 5,
    value: "U2M07EJDSB",
  },
  {
    score: 3,
    value: "4NBR9A4FMF",
  },
  {
    score: 2,
    value: "0X2ZET2CP4",
  },
  {
    score: 4,
    value: "LD4X0F70OC",
  },
];
commandResult = await redisClient.zAdd("bigboxsortedset", ssData);

console.log(
  "Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: " +
    commandResult
);

/**
 * Check sorted set data
 *
 * Command: zrange bigboxsortedset 0 -1
 * Result:
 *      1) "GM0F1JGPMJ"
 *      2) "0X2ZET2CP4"
 *      3) "4NBR9A4FMF"
 *      4) "LD4X0F70OC"
 *      5) "U2M07EJDSB"
 */
commandResult = await redisClient.zRange("bigboxsortedset", 0, -1);

console.log("Command: zrange bigboxsortedset 0 -1 | Result: ", commandResult);

/**
 * DUMP sorted set data
 *
 * Command: dump bigboxsortedset
 * Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
 */
commandResult = await redisClient.dump("bigboxsortedset");

console.log("Command: dump bigboxsortedset | Result: " + commandResult);

/**
 * Try to dump a non existing key
 * We get null
 *
 * Command: dump nonexistingkey
 * Result: (nil)
 */
commandResult = await redisClient.dump("nonexistingkey");

console.log("Command: dump nonexistingkey | Result: " + commandResult);

process.exit(0);

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: OK
Command: get bigboxstr | ResultMy string value saved in a Big Box
Command: dump bigboxstr | Result: "My string value saved in a Big Box
�3
�M�!

Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 1
Command: lrange bigboxlist 0 -1 | Result:  [ 'abc123' ]
Command: dump bigboxlist | Result: ↕☺☻☺�abc123�
T�6���l2

Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 1
Command: smembers bigboxset | Result:  [ '6218014406' ]
Command: dump bigboxset | Result: 
☺�^�r☺
‼G�GW�j▼

Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: 7
Command: hgetall bigboxhash | Result:  [Object: null prototype] {
  secret1: '3622625569',
  secret2: '5251979648',
  secret3: '7686908197',
  secret4: '0645904521',
  secret5: '8386817336',
  secret6: '2706180686',
  secret7: '7252297879'
}
Command: dump bigboxhash | Result: ►�@i@�‼��secret�!��� ↕☺      �↕��
�0645904521�♥↕
�:♠�8����♥'♠�N
M� L�`♠��HE�@%☺ �
�§��K��R

Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result:  [
  'GM0F1JGPMJ',
  '0X2ZET2CP4',
  '4NBR9A4FMF',
  'LD4X0F70OC',
  'U2M07EJDSB'
]
Command: dump bigboxsortedset | Result: ◄@MM
�GM0F1JGPMJ
☺☺�0X2ZET2CP4
☻☺�4NBR9A4FMF
♥☺�LD4X0F70OC
♦☺�U2M07EJDSB
♣☺�
�
C↓�[�

Command: dump nonexistingkey | Result: null

NOTES

  • Use the function “dump” from the package node-redis.
  • Here is the signature of the method –
    dump(key: RedisCommandArgument)
  • Definition of the RedisCommandArgument type is-
    export type RedisCommandArgument = string | Buffer
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Dump {

    public static void main(String[] args) {
        // Create connection pool
        JedisPool pool = new JedisPool("localhost", 6379);

        try (Jedis jedis = pool.getResource()) {

            /**
             * Set a string value
             *
             * Command: set bigboxstr "My string value saved in a Big Box"
             * Result: OK
             */
            String setResult = jedis.set("bigboxstr", "My string value saved in a Big Box");

            System.out.println("Command: set bigboxstr \"My string value saved in a Big Box\" | Result: " + setResult);

            /**
             * Check string value
             *
             * Command: get bigboxstr
             * Result: "My string value saved in a Big Box"
             */
            String getResult = jedis.get("bigboxstr");

            System.out.println("Command: get bigboxstr | Result" + getResult);

            /**
             * DUMP string
             *
             * Command: dump bigboxstr
             * Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
             */
            byte[] dumpResult = jedis.dump("bigboxstr");

            System.out.println("Command: dump bigboxstr | Result: " + dumpResult);


            /**
             * Add items to list
             *
             * Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
             * Result: (integer) 7
             */
            long rpushResult = jedis.rpush("bigboxlist", "abc123", "def234", "ghi345", "jkl456", "mno567", "pqrst678", "uvwxyz789");

            System.out.println("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: " + rpushResult);

            /**
             * Check list items
             *
             * Command: lrange bigboxlist 0 -1
             * Result:
             *      1) "abc123"
             *      2) "def234"
             *      3) "ghi345"
             *      4) "jkl456"
             *      5) "mno567"
             *      6) "pqrst678"
             *      7) "uvwxyz789"
             */
            List<String> lrangeResult = jedis.lrange("bigboxlist", 0, -1);

            System.out.println("Command: lrange bigboxlist 0 -1 | Result: " + lrangeResult.toString());

            /**
             * DUMP list data
             *
             * Command: dump bigboxlist
             * Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
             */
            dumpResult = jedis.dump("bigboxlist");

            System.out.println("Command: dump bigboxlist | Result: " + dumpResult);


            /**
             * Add items to set
             *
             * Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
             * Result: (integer) 5
             */
            long saddResult = jedis.sadd("bigboxset", "6218014406", "1619751279", "7858399611", "7595030997", "9982317472");

            System.out.println("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: " + saddResult);

            /**
             * Check set items
             *
             * Command: smembers bigboxset
             * Result:
             *      1) "1619751279"
             *      2) "6218014406"
             *      3) "7595030997"
             *      4) "7858399611"
             *      5) "9982317472"
             */
            Set<String> smemebersResult = jedis.smembers("bigboxset");

            System.out.println("Command: smembers bigboxset | Result: " + smemebersResult.toString());

            /**
             * DUMP set data
             *
             * Command: dump bigboxset
             * Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
             */
            dumpResult = jedis.dump("bigboxset");

            System.out.println("Command: dump bigboxset | Result: " + dumpResult);


            /**
             * Add item to hash
             *
             * Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
             * Result: (integer) 7
             */
            Map<String, String> hashData  = new HashMap<>() {{
                put("secret1", "3622625569");
                put("secret2", "5251979648");
                put("secret3", "7686908197");
                put("secret4", "0645904521");
                put("secret5", "8386817336");
                put("secret6", "2706180686");
                put("secret7", "7252297879");
            }};
            long hsetResult = jedis.hset("bigboxhash", hashData);

            System.out.println("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: " + hsetResult);

            /**
             * Check hash data
             *
             * Command: hgetall bigboxhash
             * Result:
             *      1) "secret1"
             *      2) "3622625569"
             *      3) "secret2"
             *      4) "5251979648"
             *      5) "secret3"
             *      6) "7686908197"
             *      7) "secret4"
             *      8) "0645904521"
             *      9) "secret5"
             *      10) "8386817336"
             *      11) "secret6"
             *      12) "2706180686"
             *      13) "secret7"
             *      14) "7252297879"
             */
            Map<String, String> hgetallResult = jedis.hgetAll("bigboxhash");

            System.out.println("Command: hgetall bigboxhash | Result: " + hgetallResult.toString());

            /**
             * DUMP hash data
             *
             * Command: dump bigboxhash
             * Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
             */
            dumpResult = jedis.dump("bigboxhash");

            System.out.println("Command: dump bigboxhash | Result: " + dumpResult);


            /**
             * Add item to sorted set
             *
             * Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
             * Result: (integer) 5
             */
            Map<String, Double> ssData  = new HashMap<>() {{
                put("GM0F1JGPMJ", 1.0);
                put("U2M07EJDSB", 5.0);
                put("4NBR9A4FMF", 3.0);
                put("0X2ZET2CP4", 2.0);
                put("LD4X0F70OC", 4.0);
            }};
            long zaddResult = jedis.zadd("bigboxsortedset", ssData);

            System.out.println("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: " + zaddResult);

            /**
             * Check sorted set data
             *
             * Command: zrange bigboxsortedset 0 -1
             * Result:
             *      1) "GM0F1JGPMJ"
             *      2) "0X2ZET2CP4"
             *      3) "4NBR9A4FMF"
             *      4) "LD4X0F70OC"
             *      5) "U2M07EJDSB"
             */
            List<String> zrangeResult = jedis.zrange("bigboxsortedset", 0, -1);

            System.out.println("Command: zrange bigboxsortedset 0 -1 | Result: " + zrangeResult.toString());

            /**
             * DUMP sorted set data
             *
             * Command: dump bigboxsortedset
             * Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
             */
            dumpResult = jedis.dump("bigboxsortedset");

            System.out.println("Command: dump bigboxsortedset | Result: " + dumpResult);

            /**
             * Try to dump a non existing key
             * We get null
             *
             * Command: dump nonexistingkey
             * Result: (nil)
             */
            dumpResult = jedis.dump("nonexistingkey");

            System.out.println("Command: dump nonexistingkey | Result: " + dumpResult);
        }

        pool.close();
    }
}

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: OK
Command: get bigboxstr | ResultMy string value saved in a Big Box
Command: dump bigboxstr | Result: [B@10b48321

Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 7
Command: lrange bigboxlist 0 -1 | Result: [abc123, def234, ghi345, jkl456, mno567, pqrst678, uvwxyz789]
Command: dump bigboxlist | Result: [B@6b0c2d26

Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 5
Command: smembers bigboxset | Result: [9982317472, 7858399611, 1619751279, 7595030997, 6218014406]
Command: dump bigboxset | Result: [B@641147d0

Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: 7
Command: hgetall bigboxhash | Result: {secret6=2706180686, secret7=7252297879, secret4=0645904521, secret5=8386817336, secret2=5251979648, secret3=7686908197, secret1=3622625569}
Command: dump bigboxhash | Result: [B@49070868

Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result: [GM0F1JGPMJ, 0X2ZET2CP4, 4NBR9A4FMF, LD4X0F70OC, U2M07EJDSB]
Command: dump bigboxsortedset | Result: [B@38364841

Command: dump nonexistingkey | Result: null

NOTES

  • Use method “dump” from Jedis package.
  • Signature of the method-
    public byte[] dump(final String key)
// Redis DUMP command examples in C#

using StackExchange.Redis;
using System.Text;
using System.Xml.Linq;

namespace Dump
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
            IDatabase rdb = redis.GetDatabase();


            /**
             * Set a string value
             *
             * Command: set bigboxstr "My string value saved in a Big Box"
             * Result: OK
             */
            bool setResult = rdb.StringSet("bigboxstr", "My string value saved in a Big Box");

            Console.WriteLine("Command: set bigboxstr \"My string value saved in a Big Box\" | Result: " + setResult);

            /**
             * Check string value
             *
             * Command: get bigboxstr
             * Result: "My string value saved in a Big Box"
             */
            RedisValue getResult = rdb.StringGet("bigboxstr");

            Console.WriteLine("Command: get bigboxstr | Result" + getResult);

            /**
             * DUMP string
             *
             * Command: dump bigboxstr
             * Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
             */
            byte[]? dumpResult = rdb.KeyDump("bigboxstr");

            Console.WriteLine("Command: dump bigboxstr | Result: " + Encoding.UTF8.GetString(dumpResult));

            /**
             * Add items to list
             *
             * Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
             * Result: (integer) 7
             */
            long rpushResult = rdb.ListRightPush("bigboxlist", new RedisValue[] { "abc123", "def234", "ghi345", "jkl456", "mno567", "pqrst678", "uvwxyz789" });

            Console.WriteLine("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: " + rpushResult);

            /**
                * Check list items
                *
                * Command: lrange bigboxlist 0 -1
                * Result:
                *      1) "abc123"
                *      2) "def234"
                *      3) "ghi345"
                *      4) "jkl456"
                *      5) "mno567"
                *      6) "pqrst678"
                *      7) "uvwxyz789"
                */
            RedisValue[] lrangeResult = rdb.ListRange("bigboxlist", 0, -1);

            Console.WriteLine("Command: lrange bigboxlist 0 -1 | Result: " + string.Join(", ", lrangeResult));

            /**
             * DUMP list data
             *
             * Command: dump bigboxlist
             * Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
             */
            dumpResult = rdb.KeyDump("bigboxlist");

            Console.WriteLine("Command: dump bigboxlist | Result: " + Encoding.UTF8.GetString(dumpResult));


            /**
             * Add items to set
             *
             * Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
             * Result: (integer) 5
             */
            long saddResult = rdb.SetAdd("bigboxset", new RedisValue[] { "6218014406", "1619751279", "7858399611", "7595030997", "9982317472" });

            Console.WriteLine("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: " + saddResult);

            /**
                * Check set items
                *
                * Command: smembers bigboxset
                * Result:
                *      1) "1619751279"
                *      2) "6218014406"
                *      3) "7595030997"
                *      4) "7858399611"
                *      5) "9982317472"
                */
            RedisValue[] smemebersResult = rdb.SetMembers("bigboxset");

            Console.WriteLine("Command: smembers bigboxset | Result: " + string.Join(", ", smemebersResult));

            /**
             * DUMP set data
             *
             * Command: dump bigboxset
             * Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
             */
            dumpResult = rdb.KeyDump("bigboxset");

            Console.WriteLine("Command: dump bigboxset | Result: " + Encoding.UTF8.GetString(dumpResult));

            /**
            * Add item to hash
            *
            * Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
            * Result: (integer) 7
            */
            HashEntry[] hashData = new HashEntry[] {
                new("secret1", "3622625569"),
                new("secret2", "5251979648"),
                new("secret3", "7686908197"),
                new("secret4", "0645904521"),
                new("secret5", "8386817336"),
                new("secret6", "2706180686"),
                new("secret7", "7252297879"),
             };
            rdb.HashSet("bigboxhash", hashData);

            Console.WriteLine("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879");

            /**
             * Check hash data
             *
             * Command: hgetall bigboxhash
             * Result:
             *      1) "secret1"
             *      2) "3622625569"
             *      3) "secret2"
             *      4) "5251979648"
             *      5) "secret3"
             *      6) "7686908197"
             *      7) "secret4"
             *      8) "0645904521"
             *      9) "secret5"
             *      10) "8386817336"
             *      11) "secret6"
             *      12) "2706180686"
             *      13) "secret7"
             *      14) "7252297879"
             */
            HashEntry[] hgetallResult = rdb.HashGetAll("bigboxhash");

            Console.WriteLine("Command: hgetall bigboxhash | Result: " + string.Join(", ", hgetallResult));

            /**
             * DUMP hash data
             *
             * Command: dump bigboxhash
             * Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
             */
            dumpResult = rdb.KeyDump("bigboxhash");

            Console.WriteLine("Command: dump bigboxhash | Result: " + dumpResult);

            /**
            * Add item to sorted set
            *
            * Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
            * Result: (integer) 5
            */
            List<SortedSetEntry> ssData = new List<SortedSetEntry>{
                new SortedSetEntry("GM0F1JGPMJ", 1.0),
            new SortedSetEntry("U2M07EJDSB", 5.0),
            new SortedSetEntry("4NBR9A4FMF", 3.0),
            new SortedSetEntry("0X2ZET2CP4", 2.0),
            new SortedSetEntry("LD4X0F70OC", 4.0),
                };
            long zaddResult = rdb.SortedSetAdd("bigboxsortedset", ssData.ToArray());

            Console.WriteLine("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: " + zaddResult);

            /**
             * Check sorted set data
             *
             * Command: zrange bigboxsortedset 0 -1
             * Result:
             *      1) "GM0F1JGPMJ"
             *      2) "0X2ZET2CP4"
             *      3) "4NBR9A4FMF"
             *      4) "LD4X0F70OC"
             *      5) "U2M07EJDSB"
             */
            RedisValue[] zrangeResult = rdb.SortedSetRangeByRank("bigboxsortedset", 0, -1);
            Console.WriteLine("Command: zrange bigboxsortedset 0 -1 | Result: " + string.Join(", ", zrangeResult));

            /**
             * DUMP sorted set data
             *
             * Command: dump bigboxsortedset
             * Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
             */
            dumpResult = rdb.KeyDump("bigboxsortedset");

            Console.WriteLine("Command: dump bigboxsortedset | Result: " + Encoding.UTF8.GetString(dumpResult));

            /**
             * Try to dump a non existing key
             * We get null
             *
             * Command: dump nonexistingkey
             * Result: (nil)
             */
            dumpResult = rdb.KeyDump("nonexistingkey");

            Console.WriteLine("Command: dump nonexistingkey | Result: " + dumpResult);

            redis.Close();
        }
    }
}

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: True
Command: get bigboxstr | ResultMy string value saved in a Big Box
Command: dump bigboxstr | Result: "My string value saved in a Big Box
?3
?M?!

Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 7
Command: lrange bigboxlist 0 -1 | Result: abc123, def234, ghi345, jkl456, mno567, pqrst678, uvwxyz789
Command: dump bigboxlist | Result: @DD?abc123?def234?ghi345?jkl456?mno567?pqrst678      ?uvwxyz789
?
 ?'

Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 5
Command: smembers bigboxset | Result: 1619751279, 6218014406, 7595030997, 7858399611, 9982317472
Command: dump bigboxset | Result:
oq?`?^?r????{?e???R
?,?9?f?

Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
Command: hgetall bigboxhash | Result: secret1: 3622625569, secret2: 5251979648, secret3: 7686908197, secret4: 0645904521, secret5: 8386817336, secret6: 2706180686, secret7: 7252297879
Command: dump bigboxhash | Result: System.Byte[]
Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result: GM0F1JGPMJ, 0X2ZET2CP4, 4NBR9A4FMF, LD4X0F70OC, U2M07EJDSB
Command: dump bigboxsortedset | Result: @MM
?GM0F1JGPMJ
?0X2ZET2CP4
?4NBR9A4FMF
?LD4X0F70OC
?U2M07EJDSB
?
?
C?[?

Command: dump nonexistingkey | Result:

NOTES

  • Use the method “KeyDump” from StackExchange.Redis.
  • Signature of the method is –
    byte[]? KeyDump(RedisKey key, CommandFlags flags = CommandFlags.None)
<?php
// Redis DUMP command example

require "vendor/autoload.php";

// Connect to Redis
$redisClient = new Predis\Client([
    "scheme" => "tcp",
    "host" => "localhost",
    "port" => 6379,
]);

/**
 * Set a string value
 *
 * Command: set bigboxstr "My string value saved in a Big Box"
 * Result: OK
 */
$commandResult = $redisClient->set(
    "bigboxstr",
    "My string value saved in a Big Box"
);

echo "Command: set bigboxstr \"My string value saved in a Big Box\" | Result: " .
    $commandResult .
    "\n";

/**
 * Check string value
 *
 * Command: get bigboxstr
 * Result: "My string value saved in a Big Box"
 */
$commandResult = $redisClient->get("bigboxstr");

echo "Command: get bigboxstr | Result: " . $commandResult . "\n";

/**
 * DUMP string
 *
 * Command: dump bigboxstr
 * Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
 */
$commandResult = $redisClient->dump("bigboxstr");

echo "Command: dump bigboxstr | Result: " . $commandResult . "\n";

/**
 * Add items to list
 *
 * Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
 * Result: (integer) 7
 */
$commandResult = $redisClient->rpush(
    "bigboxlist",
    "abc123",
    "def234",
    "ghi345",
    "jkl456",
    "mno567",
    "pqrst678",
    "uvwxyz789"
);

echo "Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: " .
    $commandResult .
    "\n";

/**
 * Check list items
 *
 * Command: lrange bigboxlist 0 -1
 * Result:
 *      1) "abc123"
 *      2) "def234"
 *      3) "ghi345"
 *      4) "jkl456"
 *      5) "mno567"
 *      6) "pqrst678"
 *      7) "uvwxyz789"
 */
$commandResult = $redisClient->lrange("bigboxlist", 0, -1);

echo "Command: lrange bigboxlist 0 -1 | Result: ";
print_r($commandResult);

/**
 * DUMP list data
 *
 * Command: dump bigboxlist
 * Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
 */
$commandResult = $redisClient->dump("bigboxlist");

echo "Command: dump bigboxlist | Result: " . $commandResult . "\n";

/**
 * Add items to set
 *
 * Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
 * Result: (integer) 5
 */
$commandResult = $redisClient->sAdd(
    "bigboxset",
    "6218014406",
    "1619751279",
    "7858399611",
    "7595030997",
    "9982317472"
);

echo "Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: " .
    $commandResult .
    "\n";

/**
 * Check set items
 *
 * Command: smembers bigboxset
 * Result:
 *      1) "1619751279"
 *      2) "6218014406"
 *      3) "7595030997"
 *      4) "7858399611"
 *      5) "9982317472"
 */
$commandResult = $redisClient->sMembers("bigboxset");

echo "Command: smembers bigboxset | Result: ";
print_r($commandResult);

/**
 * DUMP set data
 *
 * Command: dump bigboxset
 * Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
 */
$commandResult = $redisClient->dump("bigboxset");

echo "Command: dump bigboxset | Result: " . $commandResult . "\n";

/**
 * Add item to hash
 *
 * Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
 * Result: (integer) 7
 */
const hashData = [
    "secret1",
    "3622625569",
    "secret2",
    "5251979648",
    "secret3",
    "7686908197",
    "secret4",
    "0645904521",
    "secret5",
    "8386817336",
    "secret6",
    "2706180686",
    "secret7",
    "7252297879",
];
$commandResult = $redisClient->hmset("bigboxhash", ...hashData);

echo "Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: " .
    $commandResult .
    "\n";

/**
 * Check hash data
 *
 * Command: hgetall bigboxhash
 * Result:
 *      1) "secret1"
 *      2) "3622625569"
 *      3) "secret2"
 *      4) "5251979648"
 *      5) "secret3"
 *      6) "7686908197"
 *      7) "secret4"
 *      8) "0645904521"
 *      9) "secret5"
 *      10) "8386817336"
 *      11) "secret6"
 *      12) "2706180686"
 *      13) "secret7"
 *      14) "7252297879"
 */
$commandResult = $redisClient->hgetall("bigboxhash");

echo "Command: hgetall bigboxhash | Result: ";
print_r($commandResult);

/**
 * DUMP hash data
 *
 * Command: dump bigboxhash
 * Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
 */
$commandResult = $redisClient->dump("bigboxhash");

echo "Command: dump bigboxhash | Result: " . $commandResult . "\n";

/**
 * Add item to sorted set
 *
 * Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
 * Result: (integer) 5
 */
const ssData = [
    1.0,
    "GM0F1JGPMJ",
    5.0,
    "U2M07EJDSB",
    3.0,
    "4NBR9A4FMF",
    2.0,
    "0X2ZET2CP4",
    4.0,
    "LD4X0F70OC",
];
$commandResult = $redisClient->zadd("bigboxsortedset", ...ssData);

echo "Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: " .
    $commandResult .
    "\n";

/**
 * Check sorted set data
 *
 * Command: zrange bigboxsortedset 0 -1
 * Result:
 *      1) "GM0F1JGPMJ"
 *      2) "0X2ZET2CP4"
 *      3) "4NBR9A4FMF"
 *      4) "LD4X0F70OC"
 *      5) "U2M07EJDSB"
 */
$commandResult = $redisClient->zrange("bigboxsortedset", 0, -1);

echo "Command: zrange bigboxsortedset 0 -1 | Result: ";
print_r($commandResult);

/**
 * DUMP sorted set data
 *
 * Command: dump bigboxsortedset
 * Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
 */
$commandResult = $redisClient->dump("bigboxsortedset");

echo "Command: dump bigboxsortedset | Result: " . $commandResult . "\n";

/**
 * Try to dump a non existing key
 * We get null
 *
 * Command: dump nonexistingkey
 * Result: (nil)
 */
$commandResult = $redisClient->dump("nonexistingkey");

echo "Command: dump nonexistingkey | Result: " . $commandResult . "\n";

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: OK
Command: get bigboxstr | Result: My string value saved in a Big Box
Command: dump bigboxstr | Result: "My string value saved in a Big Box
                                                                     �3
�M�!
Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 7
Command: lrange bigboxlist 0 -1 | Result: Array
(
    [0] => abc123
    [1] => def234
    [2] => ghi345
    [3] => jkl456
    [4] => mno567
    [5] => pqrst678
    [6] => uvwxyz789
)
Command: dump bigboxlist | Result: @DD�abc123�def234�ghi345�jkl456�mno567�pqrst678   �uvwxyz789
�
 �'
Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 5
Command: smembers bigboxset | Result: Array
(
    [0] => 1619751279
    [1] => 6218014406
    [2] => 7595030997
    [3] => 7858399611
    [4] => 9982317472
)
Command: dump bigboxset | Result:
                                  oq�`�^�r����{�e���R
                                                           �,�9�f�
Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: OK
Command: hgetall bigboxhash | Result: Array
(
    [secret1] => 3622625569
    [secret2] => 5251979648
    [secret3] => 7686908197
    [secret4] => 0645904521
    [secret5] => 8386817336
    [secret6] => 2706180686
    [secret7] => 7252297879
)
Command: dump bigboxhash | Result: �@i@���secret�!���       ���
�0645904521�
           �:�8����'�N
M� L�`�HE�@%  �
                 ���K��R

Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result: Array
(
    [0] => GM0F1JGPMJ
    [1] => 0X2ZET2CP4
    [2] => 4NBR9A4FMF
    [3] => LD4X0F70OC
    [4] => U2M07EJDSB
)
Command: dump bigboxsortedset | Result: @MM
�GM0F1JGPMJ
           �0X2ZET2CP4
                        �4NBR9A4FMF
                                     �LD4X0F70OC
                                                  �U2M07EJDSB
                                                               �
                                                                  �
                                                                   C�[�
Command: dump nonexistingkey | Result:

NOTES

  • Use the method “dump” of predis.
  • Signature of the method is-
    dump(string $key): string/null
# Redis DUMP command example in Python

import redis
import time

# Create Redis client
redisClient = redis.Redis(host='localhost', port=6379,
                          username='default', password='',
                          decode_responses=True)


# Set a string value
# Command: set bigboxstr "My string value saved in a Big Box"
# Result: OK
commandResult = redisClient.set(
    "bigboxstr",
    "My string value saved in a Big Box"
)

print("Command: set bigboxstr \"My string value saved in a Big Box\" | Result: {}".format(commandResult))

# Check string value
# Command: get bigboxstr
# Result: "My string value saved in a Big Box"
commandResult = redisClient.get("bigboxstr")

print("Command: get bigboxstr | Result: {}".format(commandResult))

# DUMP string
#
# Command: dump bigboxstr
# Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
commandResult = redisClient.dump("bigboxstr")

print("Command: dump bigboxstr | Result: {}".format(commandResult))

# Add items to list
# Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
# Result: (integer) 7
commandResult = redisClient.rpush(
    "bigboxlist",
    "abc123",
    "def234",
    "ghi345",
    "jkl456",
    "mno567",
    "pqrst678",
    "uvwxyz789"
)

print("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: {}".format(commandResult))

# Check list items
# Command: lrange bigboxlist 0 -1
# Result:
#      1) "abc123"
#      2) "def234"
#      3) "ghi345"
#      4) "jkl456"
#      5) "mno567"
#      6) "pqrst678"
#      7) "uvwxyz789"
commandResult = redisClient.lrange("bigboxlist", 0, -1)

print("Command: lrange bigboxlist 0 -1 | Result: {}".format(commandResult))

# DUMP list data
# Command: dump bigboxlist
# Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
commandResult = redisClient.dump("bigboxlist")

print("Command: dump bigboxlist | Result: {}".format(commandResult))

# Add items to set
# Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
# Result: (integer) 5
commandResult = redisClient.sadd(
    "bigboxset",
    "6218014406",
    "1619751279",
    "7858399611",
    "7595030997",
    "9982317472"
)

print("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: {}".format(commandResult))

# Check set items
# Command: smembers bigboxset
# Result:
#      1) "1619751279"
#      2) "6218014406"
#      3) "7595030997"
#      4) "7858399611"
#      5) "9982317472"
commandResult = redisClient.smembers("bigboxset")

print("Command: smembers bigboxset | Result: {}".format(commandResult))

# DUMP set data
# Command: dump bigboxset
# Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
commandResult = redisClient.dump("bigboxset")

print("Command: dump bigboxset | Result: {}".format(commandResult))

# Add item to hash
# Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
# Result: (integer) 7
hashData = {
    "secret1": "3622625569",
    "secret2": "5251979648",
    "secret3": "7686908197",
    "secret4": "0645904521",
    "secret5": "8386817336",
    "secret6": "2706180686",
    "secret7": "7252297879",
};
commandResult = redisClient.hset("bigboxhash", mapping=hashData)

print("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: {}".format(commandResult))

# Check hash data
# Command: hgetall bigboxhash
# Result:
#      1) "secret1"
#      2) "3622625569"
#      3) "secret2"
#      4) "5251979648"
#      5) "secret3"
#      6) "7686908197"
#      7) "secret4"
#      8) "0645904521"
#      9) "secret5"
#      10) "8386817336"
#      11) "secret6"
#      12) "2706180686"
#      13) "secret7"
#      14) "7252297879"
commandResult = redisClient.hgetall("bigboxhash")

print("Command: hgetall bigboxhash | Result: {}".format(commandResult))

# DUMP hash data
# Command: dump bigboxhash
# Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
commandResult = redisClient.dump("bigboxhash")

print("Command: dump bigboxhash | Result: {}".format(commandResult))

# Add item to sorted set
# Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
# Result: (integer) 5
ssData = {
    "GM0F1JGPMJ": 1.0,
    "U2M07EJDSB": 5.0,
    "4NBR9A4FMF": 3.0,
    "0X2ZET2CP4": 2.0,
    "LD4X0F70OC": 4.0
};
commandResult = redisClient.zadd("bigboxsortedset", ssData)

print("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: {}".format(commandResult))

# Check sorted set data
# Command: zrange bigboxsortedset 0 -1
# Result:
#      1) "GM0F1JGPMJ"
#      2) "0X2ZET2CP4"
#      3) "4NBR9A4FMF"
#      4) "LD4X0F70OC"
#      5) "U2M07EJDSB"
commandResult = redisClient.zrange("bigboxsortedset", 0, -1)

print("Command: zrange bigboxsortedset 0 -1 | Result: {}".format(commandResult))

# DUMP sorted set data
# Command: dump bigboxsortedset
# Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
commandResult = redisClient.dump("bigboxsortedset")

print("Command: dump bigboxsortedset | Result: {}".format(commandResult))

# Try to dump a non existing key
# We get null
# Command: dump nonexistingkey
# Result: (nil)
commandResult = redisClient.dump("nonexistingkey")

print("Command: dump nonexistingkey | Result: {}".format(commandResult))

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: True
Command: get bigboxstr | Result: My string value saved in a Big Box
Command: dump bigboxstr | Result: b'\x00"My string value saved in a Big Box\x0b\x00\x07\xbf3\n\x83M\xdd!'

Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 7
Command: lrange bigboxlist 0 -1 | Result: ['abc123', 'def234', 'ghi345', 'jkl456', 'mno567', 'pqrst678', 'uvwxyz789']
Command: dump bigboxlist | Result: b"\x12\x01\x02@DD\x00\x00\x00\x07\x00\x86abc123\x07\x86def234\x07\x86ghi345\x07\x86jkl456\x07\x86mno567\x07\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"

Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 5
Command: smembers bigboxset | Result: {'1619751279', '7858399611', '7595030997', '6218014406', '9982317472'}
Command: dump bigboxset | Result: b'\x0b0\x08\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5'

Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: 7
Command: hgetall bigboxhash | Result: {'secret1': '3622625569', 'secret2': '5251979648', 'secret3': '7686908197', 'secret4': '0645904521', 'secret5': '8386817336', 'secret6': '2706180686', 'secret7': '7252297879'}
Command: dump bigboxhash | Result: b"\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\x08\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\x072\x08\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\x08\xf4%\xe9,\xca\xe0\x03\x12\r4\x08\x8a0645904521\x0b\xa0:\x065\x08\xf48\xad\xe4\xf3\xe0\x03'\x066\x08\xf4N\nM\xa1 L\xe0\x00`\x067\x08\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"

Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result: ['GM0F1JGPMJ', '0X2ZET2CP4', '4NBR9A4FMF', 'LD4X0F70OC', 'U2M07EJDSB']
Command: dump bigboxsortedset | Result: b'\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff'

Command: dump nonexistingkey | Result: None

NOTES

  • Use method “dump” from redis-py.
  • Signature of the method is –
    def dump(self, name: KeyT) -> ResponseT
# Redis DUMP command example in Ruby

require 'redis'

redis = Redis.new(host: "localhost", port: 6379)


# Set a string value
# Command: set bigboxstr "My string value saved in a Big Box"
# Result: OK
commandResult = redis.set(
    "bigboxstr",
    "My string value saved in a Big Box"
)

print("Command: set bigboxstr \"My string value saved in a Big Box\" | Result: ", commandResult, "\n")

# Check string value
# Command: get bigboxstr
# Result: "My string value saved in a Big Box"
commandResult = redis.get("bigboxstr")

print("Command: get bigboxstr | Result: ", commandResult, "\n")

# DUMP string
#
# Command: dump bigboxstr
# Result: "\x00\"My string value saved in a Big Box\x0b\x00\a\xbf3\n\x83M\xdd!"
commandResult = redis.dump("bigboxstr")

print("Command: dump bigboxstr | Result: ", commandResult, "\n")

# Add items to list
# Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789
# Result: (integer) 7
commandResult = redis.rpush("bigboxlist", [
    "abc123",
    "def234",
    "ghi345",
    "jkl456",
    "mno567",
    "pqrst678",
    "uvwxyz789"
])

print("Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: ", commandResult, "\n")

# Check list items
# Command: lrange bigboxlist 0 -1
# Result:
#      1) "abc123"
#      2) "def234"
#      3) "ghi345"
#      4) "jkl456"
#      5) "mno567"
#      6) "pqrst678"
#      7) "uvwxyz789"
commandResult = redis.lrange("bigboxlist", 0, -1)

print("Command: lrange bigboxlist 0 -1 | Result: ", commandResult, "\n")

# DUMP list data
# Command: dump bigboxlist
# Result: "\x12\x01\x02@DD\x00\x00\x00\a\x00\x86abc123\a\x86def234\a\x86ghi345\a\x86jkl456\a\x86mno567\a\x88pqrst678\t\x89uvwxyz789\n\xff\x0b\x00\x8b\xca\r \xb8\x1c'\x7f"
commandResult = redis.dump("bigboxlist")

print("Command: dump bigboxlist | Result: ", commandResult, "\n")

# Add items to set
# Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472
# Result: (integer) 5
commandResult = redis.sadd("bigboxset", [
    "6218014406",
    "1619751279",
    "7858399611",
    "7595030997",
    "9982317472"
])

print("Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: ", commandResult, "\n")

# Check set items
# Command: smembers bigboxset
# Result:
#      1) "1619751279"
#      2) "6218014406"
#      3) "7595030997"
#      4) "7858399611"
#      5) "9982317472"
commandResult = redis.smembers("bigboxset")

print("Command: smembers bigboxset | Result: ", commandResult, "\n")

# DUMP set data
# Command: dump bigboxset
# Result: "\x0b0\b\x00\x00\x00\x05\x00\x00\x00oq\x8b`\x00\x00\x00\x00\xc6^\x9fr\x01\x00\x00\x00\xd5\xf9\xb2\xc4\x01\x00\x00\x00{\xa9e\xd4\x01\x00\x00\x00\xa0\x13\xfeR\x02\x00\x00\x00\x0b\x00\xa1,\xe09\x13\xf0f\xe5"
commandResult = redis.dump("bigboxset")

print("Command: dump bigboxset | Result: ", commandResult, "\n")

# Add item to hash
# Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879
# Result: (integer) 7
hashData = {
    "secret1" => "3622625569",
    "secret2" => "5251979648",
    "secret3" => "7686908197",
    "secret4" => "0645904521",
    "secret5" => "8386817336",
    "secret6" => "2706180686",
    "secret7" => "7252297879",
};
commandResult = redis.hset("bigboxhash", mapping=hashData)

print("Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: ", commandResult, "\n")

# Check hash data
# Command: hgetall bigboxhash
# Result:
#      1) "secret1"
#      2) "3622625569"
#      3) "secret2"
#      4) "5251979648"
#      5) "secret3"
#      6) "7686908197"
#      7) "secret4"
#      8) "0645904521"
#      9) "secret5"
#      10) "8386817336"
#      11) "secret6"
#      12) "2706180686"
#      13) "secret7"
#      14) "7252297879"
commandResult = redis.hgetall("bigboxhash")

print("Command: hgetall bigboxhash | Result: ", commandResult, "\n")

# DUMP hash data
# Command: dump bigboxhash
# Result: "\x10\xc3@i@\x8e\x13\x8e\x00\x00\x00\x0e\x00\x87secret1\b\xf4!\xe1\xec\xd7 \x12\x01\x00\t\xa0\x12\a2\b\xf4\x80\xd9\n9\x01\xe0\x02\x12\x063\b\xf4%\xe9,\xca\xe0\x03\x12\r4\b\x8a0645904521\x0b\xa0:\x065\b\xf48\xad\xe4\xf3\xe0\x03'\x066\b\xf4N\nM\xa1 L\xe0\x00`\x067\b\xf4\x97HE\xb0@%\x01\t\xff\x0b\x00\xea\x15\x94\x95K\xf0\xd7R"
commandResult = redis.dump("bigboxhash")

print("Command: dump bigboxhash | Result: ", commandResult, "\n")

# Add item to sorted set
# Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC
# Result: (integer) 5
ssData = [
    [ 1.0, "GM0F1JGPMJ"],
    [ 5.0, "U2M07EJDSB"],
    [ 3.0, "4NBR9A4FMF"],
    [ 2.0, "0X2ZET2CP4"],
    [ 4.0, "LD4X0F70OC"],
];
commandResult = redis.zadd("bigboxsortedset", ssData)

print("Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: ", commandResult, "\n")

# Check sorted set data
# Command: zrange bigboxsortedset 0 -1
# Result:
#      1) "GM0F1JGPMJ"
#      2) "0X2ZET2CP4"
#      3) "4NBR9A4FMF"
#      4) "LD4X0F70OC"
#      5) "U2M07EJDSB"
commandResult = redis.zrange("bigboxsortedset", 0, -1)

print("Command: zrange bigboxsortedset 0 -1 | Result: ", commandResult, "\n")

# DUMP sorted set data
# Command: dump bigboxsortedset
# Result: "\x11@MM\x00\x00\x00\n\x00\x8aGM0F1JGPMJ\x0b\x01\x01\x8a0X2ZET2CP4\x0b\x02\x01\x8a4NBR9A4FMF\x0b\x03\x01\x8aLD4X0F70OC\x0b\x04\x01\x8aU2M07EJDSB\x0b\x05\x01\xff\x0b\x00\xba\x0bC\x19\x93[\x0f\xff"
commandResult = redis.dump("bigboxsortedset")

print("Command: dump bigboxsortedset | Result: ", commandResult, "\n")

# Try to dump a non existing key
# We get null
# Command: dump nonexistingkey
# Result: (nil)
commandResult = redis.dump("nonexistingkey")

print("Command: dump nonexistingkey | Result: ", commandResult, "\n")

Output:

Command: set bigboxstr "My string value saved in a Big Box" | Result: OK
Command: get bigboxstr | Result: My string value saved in a Big Box
Command: dump bigboxstr | Result: "My string value saved in a Big Box
�3
�M�!
Command: rpush bigboxlist abc123 def234 ghi345 jkl456 mno567 pqrst678 uvwxyz789 | Result: 7
Command: lrange bigboxlist 0 -1 | Result: ["abc123", "def234", "ghi345", "jkl456", "mno567", "pqrst678", "uvwxyz789"]
Command: dump bigboxlist | Result: ↕☺☻@DD�abc123�def234�ghi345�jkl456�mno567�pqrst678   �uvwxyz789
�
 �∟'
Command: sadd bigboxset 6218014406 1619751279 7858399611 7595030997 9982317472 | Result: 5
Command: smembers bigboxset | Result: ["1619751279", "6218014406", "7595030997", "7858399611", "9982317472"]
Command: dump bigboxset | Result: 
♣oq�`�^�r☺����☺{�e�☺�‼�R☻
�,�9‼�f�
Command: hset bigboxhash secret1 3622625569 secret2 5251979648 secret3 7686908197 secret4 0645904521 secret5 8386817336 secret6 2706180686 secret7  7252297879 | Result: 7
Command: hgetall bigboxhash | Result: {"secret1"=>"3622625569", "secret2"=>"5251979648", "secret3"=>"7686908197", "secret4"=>"0645904521", "secret5"=>"8386817336", "secret6"=>"2706180686", "secret7"=>"7252297879"}
Command: dump bigboxhash | Result: ►�@i@�‼��secret�!��� ↕☺      �↕��
�0645904521�♥↕
�:♠�8����♥'♠�N
M� L�`♠�HE�@%☺  �
�§��K��R
Command: zadd bigboxsortedset 1 GM0F1JGPMJ 5 U2M07EJDSB 3 4NBR9A4FMF 2 0X2ZET2CP4 4 LD4X0F70OC | Result: 5
Command: zrange bigboxsortedset 0 -1 | Result: ["GM0F1JGPMJ", "0X2ZET2CP4", "4NBR9A4FMF", "LD4X0F70OC", "U2M07EJDSB"]
Command: dump bigboxsortedset | Result: ◄@MM
�GM0F1JGPMJ
☺☺�0X2ZET2CP4
☻☺�4NBR9A4FMF
♥☺�LD4X0F70OC
♦☺�U2M07EJDSB
♣☺�
�
C↓�[�
Command: dump nonexistingkey | Result: 

NOTES

  • Use method “dump” from the redis-rb.
  • Signature of the method is-
    # @param [String] key
    # @return [String] serialized_value
    def dump(key)

Source Code

Use the following links to get the source code used in this article-

Related Commands

CommandDetails
RESTORE Command Details
CONFIG Command Details

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.