Redis – Scripting
Redis scripting is used to evaluate scripts using the Lua interpreter. It is built into Redis starting from version 2.6.0. The command used for scripting is EVAL command.
Syntax
Following is the basic syntax of EVAL command.
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...]
Example
Following example explains how Redis scripting works.
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 Scripting Commands
Following table lists some basic commands related to Redis Scripting.
Sr.No | Command & Description |
---|---|
1 |
Executes a Lua script. |
2 |
Executes a Lua script. |
3 |
Checks the existence of scripts in the script cache. |
4 |
Removes all the scripts from the script cache. |
5 |
Kills the script currently in execution. |
6 |
Loads the specified Lua script into the script cache. |