Functions
FCALL_RO
Invoke a read-only function
The function must be declared with the no-writes flag for it to be used with callRo.
Arguments
functionbodystringrequired
The function name.
keysbodystring[]
The keys that the function accesses.
The function can only read from the keys that are provided in the keys argument.
argsbodystring[]
The arguments for the function.
Response
unknownrequired
The return value of the function.
Example
const code = `#!lua name=ro_lib local function get_value(keys, args) return redis.call('GET', keys[1])endredis.register_function({ function_name='get_value', callback=get_value, flags={ 'no-writes' }})`;await redis.functions.load({ code, replace: true });// Call the read-only function// Note: We can modify the keys usage here, but since it represents a read-only operation// and we marked it with 'no-writes', it is safe to use callRo.const value = await redis.functions.callRo("get_value", ["mykey"])