The execution of the script is atomic, and no other scripts or Redis commands are executed when a script is running. This means that running a slow script is not a good idea, and when you run the script, other clients will think the server is busy.
There are a total of 6 Lua script-related commands:
1. Eval can evaluate the input script: eval script numkeys key [key ...] arg [arg ...]
numkeys parameter is used to specify the number of key name parameters, key Name parameter Key[key ...] from EVAL array, with 1 is accessed as a base address ( keys[1] , keys[2]&NBSP, etc.).
In a LUA script, you can use two different functions to execute Redis commands, respectively:
Redis.call ()
Redis.pcall ()
The only difference between these two functions is that they handle the errors produced by executing the commands in different ways. Redis.call () When an error occurs during the execution of a command, the script stops running and returns a script error that indicates the cause of the error. Redis.pcall () does not raise (raise) errors on error, but instead returns a LUA table with the Err field, which is used to represent errors.
2. Eval Sha can evaluate the script based on the SHA1 checksum of the script, provided that the checksum script was executed once by eval or loaded once by the script load.
3. Script load loads scripts into the script cache, but does not immediately execute the script. The return value of the command is the SHA1 checksum of the script.
4. Script Flush
Redis guarantees that all scripts that have been run are permanently saved in the script cache, which means that when an eval command executes a script successfully on a Redis instance, then all Evalsha commands for that script are executed.
The only way to flush the script cache is to call script flush in the display, which empties the cache of all scripts that have run.
5. Script exists
6. Script Kill
Redis Lua Script related