RESTORE
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).
Options
Section titled “Options”| 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.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Restored | Simple string OK |
Simple string OK |
Errors:
BUSYKEY Target key name already exists.whenkeyexists andREPLACEwas not given.ERR DUMP payload version or checksum are wrongfor a damaged payload or one from a newer format than HotKV reads.ERR Bad data formatfor a payload that passes the checksum but cannot be decoded.ERR Invalid TTL value, must be >= 0,ERR Invalid IDLETIME value, must be >= 0andERR Invalid FREQ value, must be >= 0 and <= 255.ERR syntax errorfor an unknown option, orIDLETIMEtogether withFREQ.
Examples
Section titled “Examples”127.0.0.1:6379> RESTORE greeting 0 "\x00\x05hello\t\x00\xb3\x80\x8e\xba1\xb2C\xbb"OK127.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" REPLACEOK127.0.0.1:6379> TTL greeting(integer) 60Compatibility
Section titled “Compatibility”Same options and replies as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.