Redis Scripting
# Redis Scripting
Redis scripting uses the Lua interpreter to execute scripts. Redis version 2.6 supports the Lua environment natively. The commonly used command for executing scripts is **EVAL**.
### Syntax
The basic syntax of the EVAL command is as follows:
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
### Example
The following example demonstrates how Redis scripting works:
redis 127.0.0.1:6379> EVAL "return {KEYS,KEYS,ARGV,ARGV}" 2 key1 key2 first second 1) "key1"2) "key2"3) "first"4) "second"
* * *
## Redis Scripting Commands
The table below lists common Redis scripting commands:
| No. | Command and Description |
| --- | --- |
| 1 | [EVAL script numkeys key [key ...] arg [arg ...]](#) Executes a Lua script. |
| 2 | [EVALSHA sha1 numkeys key [key ...] arg [arg ...]](#) Executes a Lua script. |
| 3 | [SCRIPT EXISTS script [script ...]](#) Checks whether the specified script has already been cached. |
| 4 | (#) Removes all scripts from the script cache. |
| 5 | (#) Kills the currently running Lua script. |
| 6 | (#) Adds the script to the script cache without executing it immediately. |
YouTip