FCALL
FCALL function numkeys [key [key ...]] [arg [arg ...]]
- Group
- Scripting and functions
- Complexity
- Depends on the function
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- slow, write
- HotKV Cloud
- All plans
- On-Premise
- no license needed
FCALL runs a function registered by a library loaded with
FUNCTION LOAD. Like a script, the function runs
atomically. It receives the numkeys key names after numkeys as its first
argument and the remaining arguments as its second. Function names are not
case-sensitive.
Unlike scripts, function libraries are part of the dataset: they are saved with snapshots and the AOF, and are copied to replicas, so they survive a restart and do not need to be reloaded by clients. See Functions for the full guide.
The function’s flags (set with redis.register_function) decide where it may
run, as for scripts: a function without no-writes is refused on a read-only
replica, and one without allow-oom when the server is over maxmemory.
Return value
Section titled “Return value”The function’s return value, converted as described for EVAL.
Errors:
ERR Function not foundwhen no loaded library registers that name.ERR Number of keys can't be greater than number of argsandERR Number of keys can't be negativefor a badnumkeys.- The
BUSY, read-only and out-of-memory errors described for EVAL.
Examples
Section titled “Examples”127.0.0.1:6379> FUNCTION LOAD "#!lua name=counters\nredis.register_function('bump', function(keys, args) return redis.call('INCRBY', keys[1], args[1]) end)""counters"127.0.0.1:6379> FCALL bump 1 hits 10(integer) 10127.0.0.1:6379> FCALL BUMP 1 hits 5(integer) 15127.0.0.1:6379> FCALL nosuch 0(error) ERR Function not foundCompatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.