Redis Lua Script related

Source: Internet
Author: User
Tags sha1

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.