restore.3valkey - Man Page
Creates a key from the serialized representation of a value.
Synopsis
RESTORE
key ttl serialized-value [REPLACE
] [ABSTTL
] [IDLETIME
seconds] [FREQ
frequency]
Description
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\c (in milliseconds) in which the key will expire.
For eviction purposes, you may use the IDLETIME
or FREQ
modifiers. See 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.
Reply
valkey-protocol(7) Simple string reply: OK
.
Complexity
O(1) to create the new key and additional O(NM) to reconstruct the serialized value, where N is the number of objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1M) where M is small, so simply O(1). However for sorted set values the complexity is O(NMlog(N)) because inserting values into sorted sets is O(log(N)).
Acl Categories
@dangerous @keyspace @slow @write
History
- Available since: 2.6.0
- Changed in 3.0.0: Added the
REPLACE
modifier. - Changed in 5.0.0: Added the
ABSTTL
modifier. - Changed in 5.0.0: Added the
IDLETIME
andFREQ
options.
Examples
127.0.0.1:6379> DEL mykey (integer) 0 127.0.0.1:6379> 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 127.0.0.1:6379> TYPE mykey list 127.0.0.1:6379> LRANGE mykey 0 -1 1) "1" 2) "2" 3) "3"
See Also
copy(3valkey), del(3valkey), dump(3valkey), exists(3valkey), expire(3valkey), expireat(3valkey), expiretime(3valkey), keys(3valkey), migrate(3valkey), move(3valkey), object(3valkey), object-encoding(3valkey), object-freq(3valkey), object-help(3valkey), object-idletime(3valkey), object-refcount(3valkey), persist(3valkey), pexpire(3valkey), pexpireat(3valkey), pexpiretime(3valkey), pttl(3valkey), randomkey(3valkey), rename(3valkey), renamenx(3valkey), scan(3valkey), sort(3valkey), sort_ro(3valkey), touch(3valkey), ttl(3valkey), type(3valkey), unlink(3valkey), wait(3valkey), waitaof(3valkey)