Hello! Is it possible to call redis functions from different user defined libraries?
As redis disables the required function in the sandboxed lua env, https://redis.io/docs/latest/develop/interact/programmability/lua-api/#:~:text=don't do it.-,Imported Lua modules,-Using imported Lua
I couldn't think of a way to solve or circumvent this.
An e.g. Load both libs
mylib1.lua
#!lua name=mylib1
local function myfunc1(keys, args)
local res = funcMyLib2
return res
end
redis.register_function('myfunc1', myfunc1)
mylib2.lua
#!lua name=mylib2
local function myfunc2(keys, args)
return "Hello from lib2"
end
redis.register_function('myfunc2', myfunc2)
I would like to be able to call myfunc1.
redis-cli FCALL myfunc1 0
(error) ERR user_function:5: Script attempted to access nonexistent global variable 'mylib2' script: myfunc1, on @user_function:5.
Use case:
We want to make mylib2 a general-purpose utility of functions that other libraries can call from their code.
Thank you for your time.
Kindly let me know if any clarification or additional context is required.
Cheers
Executing Lua in Redis