FUNCTION
Manages registered function libraries and their serialized representation.
Lua & functions · Example verified
Syntax covered here
FUNCTION LOAD library-source | FUNCTION LIST | FUNCTION DUMP | FUNCTION RESTORE payload | FUNCTION DELETE library-name | FUNCTION FLUSHThe case lists a loaded library, dumps it, flushes the catalog, restores the payload, and successfully calls the function before deleting its library.
Tested example & replies
Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.
# connection: default
> FUNCTION FLUSH
"OK"
# connection: default
> FUNCTION LOAD "#!lua name=manual\nredis.register_function{function_name='read_value', callback=function(keys,args) return redis.call('GET',keys[1]) end, flags={'no-writes'}}"
"manual"
# connection: default
> SET sample value
"OK"
# connection: default
> FUNCTION LIST
[["library_name","manual","engine","LUA","functions",[["name","read_value","description",null,"flags",["no-writes"]]]]]
# connection: default
> FUNCTION DUMP
{"base64":"9UCdIyFsdWEgbmFtZT1tYW51YWwKcmVkaXMucmVnaXN0ZXJfZnVuY3Rpb257ZnVuY3Rpb25fbmFtZT0ncmVhZF92YWx1ZScsIGNhbGxiYWNrPWZ1bmN0aW9uKGtleXMsYXJncykgcmV0dXJuIHJlZGlzLmNhbGwoJ0dFVCcsa2V5c1sxXSkgZW5kLCBmbGFncz17J25vLXdyaXRlcyd9fQsAJws2BkRcHfQ=","bytes":170}
# Capture these exact bytes as libraries.
# connection: default
> FUNCTION FLUSH
"OK"
# connection: default
> FUNCTION RESTORE <captured:libraries>
"OK"
# connection: default
> FCALL read_value 1 sample
"value"
# connection: default
> FUNCTION DELETE manual
"OK"A captured marker refers to raw bytes returned by an earlier request, not a literal string to type. Binary replies are displayed as Base64; the executable test passes the original bytes unchanged.