RESTORE

Syntax

  1. RESTORE key ttl serialized-value [REPLACE] [ABSTTL]

Time complexity: O(1) to create the new key and additional O(N_M) to reconstruct the serialized value, where N is the number of Dragonfly objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1_M) where M is small, so simply O(1). However for sorted set values the complexity is O(N_M_log(N)) because inserting values into sorted sets is O(log(N)).

Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via 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.

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

!RESTORE checks the data checksum. If it does not match an error is returned.

Return

Simple string reply: The command returns OK on success.

Examples

  1. dragonfly> DEL mykey
  2. 0
  3. dragonfly> RESTORE mykey 0 "\x0e\x01\x11\x11\x00\x00\x00\x0e\x00\x00\x00\x03\x00\x00\xf2\x02\xf3\x02\xf4\xff\t\x00\xfa\x81\x98P\x85\xf8\xd9\xed"
  4. OK
  5. dragonfly> TYPE mykey
  6. list
  7. dragonfly> LRANGE mykey 0 -1
  8. 1) "1"
  9. 2) "2"
  10. 3) "3"