当前位置:网站首页>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
边栏推荐
- Nacos installation and service registration
- Kratos战神微服务框架(一)
- KDD 2022 paper collection (under continuous update)
- [text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
- LeetCode:34. Find the first and last positions of elements in a sorted array
- Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
- IJCAI2022论文合集(持续更新中)
- Redis' bitmap
- Blue Bridge Cup_ Single chip microcomputer_ PWM output
- CSP student queue
猜你喜欢
Simclr: comparative learning in NLP
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
Persistence practice of redis (Linux version)
Mise en œuvre de la quantification post - formation du bminf
Intel distiller Toolkit - Quantitative implementation 1
The carousel component of ant design calls prev and next methods in TS (typescript) environment
KDD 2022 paper collection (under continuous update)
How to intercept the string correctly (for example, intercepting the stock in operation by applying the error information)
Intel Distiller工具包-量化实现2
Withdrawal of wechat applet (enterprise payment to change)
随机推荐
Solve the problem of inconsistency between database field name and entity class attribute name (resultmap result set mapping)
Redis之五大基础数据结构深入、应用场景
go-redis之初始化连接
Le modèle sentinelle de redis
CSP student queue
Appears when importing MySQL
LeetCode:162. Looking for peak
【图的三大存储方式】只会用邻接矩阵就out了
go-redis之初始化連接
Global and Chinese market of capacitive displacement sensors 2022-2028: Research Report on technology, participants, trends, market size and share
Advanced Computer Network Review(3)——BBR
Sentinel mode of redis
基于B/S的医院管理住院系统的研究与实现(附:源码 论文 sql文件)
Leetcode: Sword finger offer 48 The longest substring without repeated characters
Blue Bridge Cup_ Single chip microcomputer_ Measure the frequency of 555
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of cup masks 2022-2028: Research Report on technology, participants, trends, market size and share
什么是MySQL?MySql的学习之路是怎样的
Pytest parameterization some tips you don't know / pytest you don't know
What is an R-value reference and what is the difference between it and an l-value?