Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

RESTORE

Last updated
RESTORE key ttl serialized-value [REPLACE] [ABSTTL] [IDLETIME seconds] [FREQ frequency]
Group
Keys
Complexity
O(N) where N is the size of the value
Arity
-4 (at least 4 words, counting the command name)
Flags
write
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

RESTORE creates key from a payload made by DUMP. It accepts payloads from HotKV and from Redis. ttl is the time to live in milliseconds, or 0 for none. If the time to live has already passed, the command succeeds but no key is left (with REPLACE, an existing key of that name is deleted).

Option Effect
REPLACE Overwrite key if it exists. Without it, an existing key is an error.
ABSTTL Read ttl as an absolute Unix time in milliseconds instead of a duration.
IDLETIME seconds Set the key’s idle time, used when the eviction policy is LRU-based. Must be 0 or more.
FREQ frequency Set the key’s access frequency, used when the eviction policy is LFU-based. Must be 0 to 255.

IDLETIME and FREQ cannot be combined. The options are checked first, then whether the key exists, then the time to live.

Case RESP2 RESP3
Restored Simple string OK Simple string OK

Errors:

  • BUSYKEY Target key name already exists. when key exists and REPLACE was not given.
  • ERR DUMP payload version or checksum are wrong for a damaged payload or one from a newer format than HotKV reads.
  • ERR Bad data format for a payload that passes the checksum but cannot be decoded.
  • ERR Invalid TTL value, must be >= 0, ERR Invalid IDLETIME value, must be >= 0 and ERR Invalid FREQ value, must be >= 0 and <= 255.
  • ERR syntax error for an unknown option, or IDLETIME together with FREQ.
127.0.0.1:6379> RESTORE greeting 0 "\x00\x05hello\t\x00\xb3\x80\x8e\xba1\xb2C\xbb"
OK
127.0.0.1:6379> GET greeting
"hello"
127.0.0.1:6379> RESTORE greeting 0 "\x00\x05hello\t\x00\xb3\x80\x8e\xba1\xb2C\xbb"
(error) BUSYKEY Target key name already exists.
127.0.0.1:6379> RESTORE greeting 60000 "\x00\x05hello\t\x00\xb3\x80\x8e\xba1\xb2C\xbb" REPLACE
OK
127.0.0.1:6379> TTL greeting
(integer) 60

Same options and replies as Redis 7 and Valkey 8.

DUMP, RESTORE-ASKING, MIGRATE, COPY