Latest web development tutorials

Redis script

Redis Lua script interpreter to execute the script. Reids 2.6 version supported by the embedded Lua environment. Common command script forEVAL.

grammar

Eval basic syntax of the command is as follows:

redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]

Examples

The following example demonstrates redis script work process:

redis 127.0.0.1:6379> EVAL "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second

1) "key1"
2) "key2"
3) "first"
4) "second"

Redis script commands

The following table lists the redis script common commands:

No. Command and description
1 EVAL script numkeys key [key ...] arg [arg ...]
Executive Lua script.
2 EVALSHA sha1 numkeys key [key ...] arg [arg ...]
Executive Lua script.
3 SCRIPT EXISTS script [script ...]
Specifies whether the script has been saved in the cache them.
4 SCRIPT FLUSH
Remove all scripts from the script cache.
5 SCRIPT KILL
Kill Lua scripts that are currently running.
6 SCRIPT LOAD script
Add the script to the script cache script, but the script does not execute immediately.