Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages of Redis->eval()

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what are the advantages of Redis- > eval (), I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Do you often use get () and set () when you use Redis? In fact, there are many useful data structures in Redis, as well as various methods. Today we're going to test the eval () method.

Redis Eval official note (excerpt)

EVAL script numkeys key [key...] Arg [arg...]

Starting with Redis version 2.6.0, Lua scripts can be evaluated using the EVAL command through the built-in Lua interpreter.

Redis uses a single Lua interpreter to run all scripts, and Redis ensures that scripts are executed in an atomic manner: when a script is running, no other scripts or Redis commands are executed. This is similar to a transaction surrounded by MULTI / EXEC. To other clients, the script's effect is either invisible (not visible) or completed (already completed).

On the other hand, it also means that it's not a good idea to execute a slow script. It is not difficult to write a script that runs quickly and smoothly, because the overhead of the script is very small, but be careful when you have to use some slow scripts, because when these snail scripts are running slowly, other clients will be unable to execute commands because the server is busy.

Actual measurement

As far as I understand it, the eval () method in Redis is generally used in scenarios where multiple redis operations need to be performed to accomplish a goal.

Below I simulate a scenario of operating redis 100 times, of course, you may not need so many, just want you to see the difference.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report