Back to Redis

RESTORE

content/commands/restore.md

latest1.9 KB
Original Source

Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via [DUMP]({{< relref "/commands/dump" >}})).

If ttl is 0 the key is created without any expire, otherwise the specified expire time (in milliseconds) is set.

If the ABSTTL modifier was used, ttl should represent an absolute Unix timestamp (in milliseconds) in which the key will expire.

For eviction purposes, you may use the IDLETIME or FREQ modifiers. See [OBJECT]({{< relref "/commands/object" >}}) for more information.

RESTORE will return a "Target key name is busy" error when key already exists unless you use the REPLACE modifier.

RESTORE checks the RDB version and data checksum. If they don't match an error is returned.

Examples

redis> DEL mykey
0
redis> RESTORE mykey 0 "\n\x17\x17\x00\x00\x00\x12\x00\x00\x00\x03\x00\
                        x00\xc0\x01\x00\x04\xc0\x02\x00\x04\xc0\x03\x00\
                        xff\x04\x00u#<\xc0;.\xe9\xdd"
OK
redis> TYPE mykey
list
redis> LRANGE mykey 0 -1
1) "1"
2) "2"
3) "3"

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Not supported">❌ Active-Active*</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Not supported">❌ Active-Active*</nobr></span> | *Only supported for module keys. |

Return information

{{< multitabs id="restore-return-info" tab1="RESP2" tab2="RESP3" >}}

Simple string reply: OK.

-tab-sep-

Simple string reply: OK.

{{< /multitabs >}}