SCRIPT
Since 1.1.0Scripting
Syntax
SCRIPTSCRIPT is a container: its subcommands manage the cache of Lua scripts that EVAL and SCRIPT LOAD fill and EVALSHA runs from, and the script running now.
| Subcommand | |
|---|---|
SCRIPT LOAD | cache a script without running it, and return its SHA1 digest |
SCRIPT EXISTS | whether scripts are in the cache, by digest |
SCRIPT FLUSH | empty the cache |
SCRIPT KILL | stop the script running, if it has not written |
SCRIPT DEBUG | accepted for compatibility; there is no debugger |
SCRIPT HELP | list the subcommands (since 1.2.1) |
Libraries of functions are managed with FUNCTION instead. Scripting explains how scripts are cached, how they run alongside each other, and how they differ from Redis's.
Lua is in the lua and full builds only. In the default build, every SCRIPT subcommand gets ERR this build of KiviDB has no Lua: EVAL, SCRIPT, FUNCTION and FCALL need the lua or full variant (Docker image kividb/kividb:v1.2.2-lua, or a kividb-lua release file).
SCRIPT alone, or with a name it does not know, such as NOPE, is an error. Since 1.2.1 the error is Redis's, which names the subcommand and suggests SCRIPT HELP; before, it was ERR unknown subcommand 'nope' for SCRIPT.
Examples
> SCRIPT
(error) ERR wrong number of arguments for 'script' command
> SCRIPT NOPE
(error) ERR unknown subcommand 'NOPE'. Try SCRIPT HELP.
Subcommands
- SCRIPT DEBUG: Accepted for compatibility with Redis, and replies OK, but does nothing: KiviDB has no Lua debugger.
- SCRIPT EXISTS: Tells, for each SHA1 digest given, whether the server has that script in its cache, so that EVALSHA can run it.
- SCRIPT FLUSH: Empties the script cache: every script loaded with SCRIPT LOAD or sent with EVAL is forgotten, and EVALSHA of any of them gets NOSCRIPT until the script is sent again.
- SCRIPT HELP: Lists the SCRIPT subcommands, with a line or two on what each does, as Redis does.
- SCRIPT KILL: Stops the script running, if it has not written anything.
- SCRIPT LOAD: Puts a script in the server's cache, without running it, and returns its SHA1 digest.