EVAL_RO
EVAL_RO script numkeys [key [key ...]] [arg [arg ...]]
- Group
- Scripting and functions
- Complexity
- Depends on the script
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- slow, read-only
- HotKV Cloud
- All plans
- On-Premise
- no license needed
EVAL_RO runs a Lua script like EVAL, but the script may
not write. Because the command itself is read-only, you can send it to
read-only replicas and grant it to users who are not allowed to write. Any
write command the script tries fails with
ERR Write commands are not allowed from read-only scripts.
A script with a shebang line must declare the no-writes flag to run with
EVAL_RO; otherwise it is refused before it starts.
Return value
Section titled “Return value”The script’s return value, converted as described for EVAL.
Errors, in addition to those of EVAL:
ERR Can not execute a script with write flag using *_ro command.for a script with a shebang line that lacksno-writes.ERR Write commands are not allowed from read-only scripts.when the script tries to write.
Examples
Section titled “Examples”127.0.0.1:6379> SET greeting "hello"OK127.0.0.1:6379> EVAL_RO "return redis.call('GET', KEYS[1])" 1 greeting"hello"127.0.0.1:6379> EVAL_RO "#!lua flags=no-writesreturn redis.call('STRLEN', KEYS[1])" 1 greeting(integer) 5Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.