Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

EVAL_RO

Last updated
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.

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 lacks no-writes.
  • ERR Write commands are not allowed from read-only scripts. when the script tries to write.
127.0.0.1:6379> SET greeting "hello"
OK
127.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-writes
return redis.call('STRLEN', KEYS[1])" 1 greeting
(integer) 5

Same as Redis 7 and Valkey 8.

EVAL, EVALSHA_RO, FCALL_RO