FCALL to invoke a function from a library loaded with FUNCTION LOAD.
<numkeys> tells the server how many of the arguments that follow are key names. Those keys reach the function in KEYS and every remaining argument in ARGV. Passing key names as keys instead of hardcoding them in the function body matters, because Redis uses that list for routing and access checks.
The function runs on the server as a single atomic step, so a sequence of reads and writes that would otherwise need several round trips and a transaction becomes one command. Use FCALL_RO when the function only reads. Functions are the successor to EVAL scripts: they are named, registered once as part of a library, and persisted with the dataset instead of being sent or looked up by digest on every call.
Upstash runs a function under the global lock by default, since the engine cannot know in advance which keys it will touch. Registering the function with the allow-key-locking flag makes the call lock only the keys passed in the key list, so calls that work on disjoint keys run in parallel:
FCALL call: keys sent as ordinary arguments are not locked, and commands that need database-wide access, such as FLUSHDB, are rejected. See Key-Based Locking for the full rules.
Syntax
Arguments
Important points
numkeysmust equal the number of key arguments that immediately follow it; remaining arguments are available to the script or function as ordinary arguments.- The function takes the global lock unless it was registered with the
allow-key-lockingflag, in which case only the keys passed in the key list are locked. See Key-Based Locking. - Pass every key the function touches in the key list whether or not
allow-key-lockingis set. A key built inside the function is read from disk under the lock when it is not in memory, and it is rejected outright when the flag is set. See Dynamic Keys and Latency.
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
upstash_redis
upstash_redis
This command is not supported yet in
upstash_redis.ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs