EVAL_RO(3valkey)
β¨ NAME β¨
eval_ro β executes a read-only server-side Lua script, and honestly? iconic behavior. π
This lil page lives in the Valkey Command Manual, and yes bestie, eval_ro(3valkey) is the star of the show.
πΈ SYNOPSIS πΈ
EVAL_RO script numkeys key [key...] arg [arg...]
(yes the spacing is exactly like that, don't come for me π«Ά)
π DESCRIPTION π
okay so. This is the read-only variant of the EVAL command from valkey-eval(7). Same vibe, one big difference: it cannot execute commands that modify data. Nope. Not happening. The vibes are strictly observational. π«β¨
Wanna know when you should reach for this one vs plain old EVAL? The details are over in the Read-only scripts section of valkey-programmability(7). Go read it, I'll wait. π
And if you want the full lore drop on EVAL scripts in general, that's the Introduction to Eval Scripts section in valkey-eval-intro(7). It's giving "required reading". π
π«Ά REPLY π«Ά
The return value depends on the script that was executed. That's it, that's the whole reply. Whatever your script hands back is what you get. π¦
π₯ COMPLEXITY π₯
Depends on the script that is executed. No cap, it's literally just the script's problem, not ours. π
π ACL CATEGORIES π
@scripting @slow
π¦ HISTORY π¦
- Available since:
7.0.0β she's been around, she's established, she's a main character. β
π EXAMPLES π
Watch this. First we set a key like normal:
> SET mykey "Hello"
OK
Then we run a read-only script that grabs it β and look at that, it works beautifully:
> EVAL_RO "return server.call('GET', KEYS[1])" 1 mykey
"Hello"
And now the part where the script tries to be messy and the server says absolutely not:
> EVAL_RO "return server.call('DEL', KEYS[1])" 1 mykey
(error) ERR Error running script (call to b0d697da25b13e49157b2c214a4033546aba2104): @user_script:1: @user_script: 1: Write commands are not allowed from read-only scripts.
bestie. Read the last line again. Write commands are not allowed from read-only scripts. That's the whole point of this command. DEL is a write command, so it gets vetoed. periodt. π«π
π SEE ALSO π
eval(3valkey), evalsha(3valkey), evalsha_ro(3valkey), fcall(3valkey), fcall_ro(3valkey), function(3valkey), function-delete(3valkey), function-dump(3valkey), function-flush(3valkey), function-help(3valkey), function-kill(3valkey), function-list(3valkey), function-load(3valkey), function-restore(3valkey), function-stats(3valkey), script(3valkey), script-debug(3valkey), script-exists(3valkey), script-flush(3valkey), script-help(3valkey), script-kill(3valkey), script-load(3valkey), script-show(3valkey)
(go read the whole family, they're all slaying in their own way π§π)
and that's the page!! π This one's from Valkey 9.0.0, dated 2025-10-21, and yes β it really is the EVAL_RO(3valkey) manual page, just with way better energy. mwah. ππΈβ¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms