当前位置:网站首页>Lua script of redis
Lua script of redis
2022-07-06 09:21:00 【~Pompeii】
Catalog
Redis And Lua Script
1.Redis Script Introduction
Redis Script use Lua Interpreter to execute the script ,Reids Supported by inline Lua Environmental Science .
2.eval
The common command to execute a script is EVAL.
Parameter description :
1.script: The argument is a segment Lua 5.1 Script program . Scripts don't have to ( Should not be ) Define as a Lua function .
2.numkeys: Used to specify the number of key name parameters .
3.key [key …]: from EVAL The third parameter starts to count , Represents those used in scripts Redis key (key), These key name parameters can be found in Lua Through global variables KEYS Array , use 1 Form access for the base address ( KEYS[1] , KEYS[2] , And so on ).
4.arg [arg …]: Additional parameters , stay Lua Through global variables ARGV Array access , The form of access and KEYS Variables like ( ARGV[1] 、 ARGV[2] , And so on ).
EVAL script numkeys key [key ...] arg [arg ...]
3.evalsha
Evalsha The command is based on the given sha1 Check code , Executing scripts cached in the server .
Parameter description :
1.script: The argument is a segment Lua 5.1 Script program . Scripts don't have to ( Should not be ) Define as a Lua function .
2.numkeys: Used to specify the number of key name parameters .
3.key [key …]: from EVAL The third parameter starts to count , Represents those used in scripts Redis key (key), These key name parameters can be found in Lua Through global variables KEYS Array , use 1 Form access for the base address ( KEYS[1] , KEYS[2] , And so on ).
4.arg [arg …]: Additional parameters , stay Lua Through global variables ARGV Array access , The form of access and KEYS Variables like ( ARGV[1] 、 ARGV[2] , So
EVALSHA sha1 numkeys key [key ...] arg [arg ...]
4.script kill
Script kill The command is used to kill the currently running Lua Script , If and only if the script does not perform any write operations , This order will take effect .
This command is mainly used to terminate long running scripts , Like one because BUG And the script with infinite loop .
SCRIPT KILL After performing , The currently running script will be killed , The client executing this script will run from EVAL Exit from the command block , And receive an error as the return value .
Return value : Always returns OK
SCRIPT KILL
5.script load
Redis Script Load The command is used to put the script script Add to script cache , But the script is not executed immediately .
EVAL The command also adds the script to the script cache , But it immediately evaluates the input script .
If the given script is already in the cache , Then do nothing .
After the script is added to the cache , adopt EVALSHA command , You can use script SHA1 Checksum to invoke this script .
Scripts can stay in the cache for an infinite amount of time , Until the execution of SCRIPT FLUSH until .
Return value : Of a given script SHA1 The checksum
SCRIPT LOAD script
6.script exists
Script Exists Command is used to verify whether the specified script has been saved in the cache .
Return value :
A list of , contain 0 and 1 , The former means that the script does not exist in the cache , The latter means that the script is already in the cache .
The elements in the list and the given SHA1 Check and keep the corresponding relationship , For example, the value of the third element in the list represents the third SHA1 The state of the script specified by the checksum in the cache .
SCRIPT EXISTS sha1 [sha1 ...]
7.script flush
Flush The command is used to clear all Lua Script cache .
Return value : Always returns OK
SCRIPT FLUSH
边栏推荐
- Implement window blocking on QWidget
- Parameterization of postman
- Mathematical modeling 2004b question (transmission problem)
- Kratos ares microservice framework (I)
- Intel distiller Toolkit - Quantitative implementation 2
- Global and Chinese market of cup masks 2022-2028: Research Report on technology, participants, trends, market size and share
- Using label template to solve the problem of malicious input by users
- Solve the problem of inconsistency between database field name and entity class attribute name (resultmap result set mapping)
- Redis之Geospatial
- postman之参数化详解
猜你喜欢
Le modèle sentinelle de redis
Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
Solve the problem of inconsistency between database field name and entity class attribute name (resultmap result set mapping)
Selenium+pytest automated test framework practice
QML control type: Popup
Intel Distiller工具包-量化实现2
A convolution substitution of attention mechanism
Selenium+pytest automated test framework practice (Part 2)
【图的三大存储方式】只会用邻接矩阵就out了
LeetCode41——First Missing Positive——hashing in place & swap
随机推荐
Redis' performance indicators and monitoring methods
Implement window blocking on QWidget
BN folding and its quantification
Redis之五大基础数据结构深入、应用场景
使用标签模板解决用户恶意输入的问题
KDD 2022论文合集(持续更新中)
Global and Chinese market of AVR series microcontrollers 2022-2028: Research Report on technology, participants, trends, market size and share
[OC foundation framework] - string and date and time >
Multivariate cluster analysis
注意力机制的一种卷积替代方式
Post training quantification of bminf
Pytest参数化你不知道的一些使用技巧 /你不知道的pytest
Connexion d'initialisation pour go redis
Intel distiller Toolkit - Quantitative implementation 3
自定义卷积注意力算子的CUDA实现
[three storage methods of graph] just use adjacency matrix to go out
I-BERT
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
What is MySQL? What is the learning path of MySQL
LeetCode:124. Maximum path sum in binary tree