English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Evalsha command

Redis Scripts

The Redis Evalsha command based on the given sha1 Verification code, execute the script cached on the server.

The operation of caching scripts to the server can be performed through the SCRIPT LOAD command.

In other places of this command, such as the way parameters are passed, are the same as those of the EVAL command.

Syntax

Basic Syntax of Redis Evalsha Command:

redis 127.0.0.1:6379> EVALSHA sha1 numkeys key [key ...] arg [arg ...] 

Parameter Description:

  • sha1 : The sha generated by SCRIPT LOAD.1 Checksum.
  • numkeys: Used to specify the number of key name parameters.
  • key [key ...]: Starting from the third parameter of EVAL, indicating those Redis keys (key) used in the script, these key name parameters can be accessed in Lua through the global variable KEYS array, using 1 : Access in the form of a base address ( KEYS[1] , KEYS[2] ,etc.).
  • arg [arg ...]: Additional parameters, accessible in Lua through the global variable ARGV array, accessed in a similar manner to KEYS ( ARGV[1] 、 ARGV[2] , such as these).

Available Versions

>= 2.6.0

Online Examples

redis 127.0.0.1:6379> SCRIPT LOAD "return 'hello moto'"
"232fd51614574cf0867b83d384a5e898cfd24e5a"
redis 127.0.0.1:6379> EVALSHA "232fd51614574cf0867b83d384a5e898cfd24e5a" 0
"hello moto"

Redis Scripts