{"id":26074,"date":"2022-07-17T11:53:38","date_gmt":"2022-07-17T01:53:38","guid":{"rendered":"https:\/\/database.guide\/?p=26074"},"modified":"2022-07-17T11:53:38","modified_gmt":"2022-07-17T01:53:38","slug":"redis-dump-command-explained","status":"publish","type":"post","link":"https:\/\/database.guide\/redis-dump-command-explained\/","title":{"rendered":"Redis DUMP Command Explained"},"content":{"rendered":"\n<p>The Redis <code>DUMP<\/code> command serialises the value stored at a specified key in a Redis-specific format and returns it to the user.<\/p>\n\n\n\n<p>The serialisation format contains a 64-bit checksum that is used to make sure errors will be detected. The values are&nbsp;in the same format used by the RDB. Also, an RDB version is encoded inside the serialised value, so that different Redis versions with incompatible RDB formats will refuse to process the serialised value.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>DUMP key<\/code><\/pre>\n\n\n\n<p>Where <code>key<\/code> is the key for whose value we want to serialise.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<p>Suppose we set a key\/value pair:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SET type \"Dog\"<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">OK<\/pre>\n\n\n\n<p>In this case, <code>type<\/code> the key and <code>\"Dog\"<\/code> is its value. <\/p>\n\n\n\n<p>Now let&#8217;s use <code>DUMP<\/code> against that value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DUMP type<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\"\\x00\\x03Dog\\n\\x00\\x14\\x069\\xb24\\x14\\xe4\\xd6\"<\/pre>\n\n\n\n<p>Note that the serialised value does not contain expire information. We can use the <code><a href=\"https:\/\/database.guide\/redis-ttl-command-explained\/\" data-type=\"post\" data-id=\"26179\">TTL<\/a><\/code> or <code><a href=\"https:\/\/database.guide\/redis-pttl-command-explained\/\" data-type=\"post\" data-id=\"26158\">PTTL<\/a><\/code> commands to get expire information for a given key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When the Key Doesn&#8217;t Exist<\/h2>\n\n\n\n<p>If the key doesn&#8217;t exist, <code>DUMP<\/code> returns <code>nil<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DUMP nonexistentkey<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(nil)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Restore the Value<\/h2>\n\n\n\n<p>We can use the <code><a href=\"https:\/\/database.guide\/redis-restore-command-explained\/\" data-type=\"post\" data-id=\"26082\">RESTORE<\/a><\/code> command to restore the serialised data back to its original form.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Redis DUMP command serialises the value stored at a specified key in a Redis-specific format and returns it to the user. The serialisation format contains a 64-bit checksum that is used to make sure errors will be detected. The values are&nbsp;in the same format used by the RDB. Also, an RDB version is encoded &#8230; <a title=\"Redis DUMP Command Explained\" class=\"read-more\" href=\"https:\/\/database.guide\/redis-dump-command-explained\/\" aria-label=\"Read more about Redis DUMP Command Explained\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[153],"tags":[154,20],"class_list":["post-26074","post","type-post","status-publish","format-standard","hentry","category-redis","tag-commands","tag-what-is"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/26074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=26074"}],"version-history":[{"count":5,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/26074\/revisions"}],"predecessor-version":[{"id":26441,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/26074\/revisions\/26441"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=26074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=26074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=26074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}