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.

FUNCTION RESTORE

Last updated
FUNCTION RESTORE serialized-value [FLUSH | APPEND | REPLACE]
Group
Scripting and functions
Complexity
O(N) where N is the number of libraries
Arity
-3 (at least 3 words, counting the command name)
HotKV Cloud
All plans
On-Premise
no license needed

FUNCTION RESTORE loads the libraries in a payload made by FUNCTION DUMP. It is all or nothing: if any library fails to load, the libraries that were loaded before the command are put back and nothing changes.

Policy Effect
APPEND Add the payload’s libraries. Fails if any of them is already loaded. This is the default.
REPLACE Add the payload’s libraries, replacing loaded libraries of the same name.
FLUSH Delete all loaded libraries first, then load the payload’s.
Case RESP2 RESP3
Restored Simple string OK Simple string OK

Errors:

  • ERR Library <name> already exists with APPEND when a library in the payload is already loaded.
  • ERR Wrong restore policy given, value should be either FLUSH, APPEND or REPLACE.
  • Any FUNCTION LOAD error for a library in the payload.
127.0.0.1:6379> FUNCTION DUMP
"#!lua name=util\nredis.register_function('echo', function(keys, args) return args[1] end)\x00"
127.0.0.1:6379> FUNCTION FLUSH
OK
127.0.0.1:6379> FUNCTION RESTORE "#!lua name=util\nredis.register_function('echo', function(keys, args) return args[1] end)\x00"
OK
127.0.0.1:6379> FCALL echo 0 "back"
"back"

Same policies and replies as Redis 7 and Valkey 8, but only HotKV payloads are accepted (see FUNCTION DUMP).

FUNCTION DUMP, FUNCTION LOAD, FUNCTION FLUSH