redis RESTORE command
Translation results:
UK[rɪˈstɔ:(r)] US[rɪˈstɔr, -ˈstor]
vt. Repair; return; hand over; restore
vt.& vi. Restore (a certain situation or feeling); restore; reset; reinstate
Third person singular: restores Present participle: restoring Past tense: restored Past participle: restored
redis RESTORE commandsyntax
Function: Deserialize the given serialized value and associate it with the given key. The parameter ttl sets the survival time for key in milliseconds; if ttl is 0, then the survival time is not set.
Syntax: RESTORE key ttl serialized-value
Description: RESTORE will first serialize the RDB version of the value before performing deserialization Check with the data checksum. If the RDB version is different or the data is incomplete, RESTORE will refuse to deserialize and return an error.
Available versions: >= 2.6.0Time complexity: The complexity of finding a given key is O(1) and deserializing the key The complexity is O(N*M), where N is the number of Redis objects that constitute key, and M is the average size of these objects. The deserialization complexity of a sorted set is O(N*M*log(N)) because the complexity of each insertion into a sorted set is O(log(N)) . If the deserialized object is a relatively small string, the complexity is O(1).
Return: If deserialization is successful, return OK, otherwise return an error.
redis RESTORE commandexample
redis> SET greeting "hello, dumping world!" OK redis> DUMP greeting "\x00\x15hello, dumping world!\x06\x00E\xa0Z\x82\xd8r\xc1\xde" redis> RESTORE greeting-again 0 "\x00\x15hello, dumping world!\x06\x00E\xa0Z\x82\xd8r\xc1\xde" OK redis> GET greeting-again "hello, dumping world!" redis> RESTORE fake-message 0 "hello moto moto blah blah" ; 使用错误的值进行反序列化 (error) ERR DUMP payload version or checksum are wrong