English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis scripts use the Lua interpreter to execute scripts. Redis 2.6 Version supports Lua environment through embedding. The commonly used command to execute scripts is EVAL.
The basic syntax of the Eval command is as follows:
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
The following examples demonstrate the working process of redis scripts:
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"
The following table lists the commonly used redis script commands:
Serial Number | Command and Description |
---|---|
1 | EVAL script numkeys key [key ...] arg [arg ...] Execute Lua script. |
2 | EVALSHA sha1 numkeys key [key ...] arg [arg ...] Execute Lua script. |
3 | SCRIPT EXISTS script [script ...] Check if the specified script has been saved in the cache. |
4 | SCRIPT FLUSH Remove all scripts from the script cache. |
5 | SCRIPT KILL Kill the currently running Lua script. |
6 | SCRIPT LOAD script Add the script script to the script cache but do not execute this script immediately. |