Functions
FCALL
Invoke a function.
Arguments
functionbodystringrequired
The function name.
keysbodystring[]
The keys that the function accesses.
The function can only read/write from the keys that are provided in the keys argument.
argsbodystring[]
The arguments for the function.
Response
unknownrequired
The return value of the function.
Basic
const code = `#!lua name=mylibredis.register_function('helloworld', function() return 'Hello World!' end)`;await redis.functions.load({ code, replace: true });const res = await redis.functions.call("helloworld");console.log(res); // "Hello World!"Advanced
const code = `#!lua name=mylibredis.register_function('my_hset', function (keys, args) local hash = keys[1] local time = redis.call('TIME')[1] return redis.call('HSET', hash, '_last_modified_', time, unpack(args)) end)`;await redis.functions.load({ code, replace: true });const res = await redis.functions.call( "my_hset", ["myhash"], [ "myfield", "some value", "another_field", "another value", ],);