EVALSHA_RO to run a script cached by its SHA1 digest. The script may not write to the database.
It is the read-only form of EVALSHA: any write command called from the script fails, which lets the server run it on replicas. As with EVALSHA, a digest that is not in the cache produces a NOSCRIPT error, and the caller is expected to fall back to EVAL_RO with the script body.
Read-only scripts take the global lock like any other script unless the cached body’s shebang sets the allow-key-locking flag, for example #!lua flags=no-writes,allow-key-locking. With the flag, the call takes shared read locks on the keys passed in KEYS. See Key-Based Locking.
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.- A read-only script still takes the global lock unless the cached body’s shebang sets the
allow-key-lockingflag. See Key-Based Locking. - Pass every key the script reads through
KEYSwhether or notallow-key-lockingis set. A key built inside the script 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
ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs