w3resource

Redis Keys: Restore

RESTORE key ttl serialized-value [REPLACE]

The Redis RESTORE command is used to 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.

Syntax:

RESTORE key 0 "serialized value"

Available since

2.6.0.

Return Value

Simple string reply: The command returns OK on success.

Return Value Type

String

Example: Redis RESTORE

First, create some keys in redis and set some values in it.

127.0.0.1:6379> SET key "Apple"
OK
127.0.0.1:6379> Dump key
"\x00\x05Apple\x06\x00\r\x88\x03\xb7\x96\x16\xf6p"
127.0.0.1:6379> DEL key
(integer) 1
127.0.0.1:6379> restore key 0 "\x00\x05Apple\x06\x00\r\x88\x03\xb7\x96\x16\xf6p"
OK
127.0.0.1:6379> GET key
"Apple"

Previous: RENAMENX
Next: SCAN



Follow us on Facebook and Twitter for latest update.