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

Case Analysis of redis script Command execution

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "redis script command execution problem case analysis". The editor shows you the operation process through the actual case, and the operation method is simple, fast and practical. I hope this "redis script command execution problem case analysis" article can help you solve the problem.

1. Execute in the redis-cli command line: # call the redis command to set the cache # do not pass the parameter eval "return redis.call ('set',' name1', 'Tom')" pass a value parameter eval "return redis.call (' set', 'name2', ARGV [1])" 0 "Tom" # pass a key parameter and a value parameter eval "return redis.call (' set', KEYS [1]) ARGV [1]) "1" name3 "Tom" 2, execute on the linux command line: # specify the path to the lua script Unlike in redis-cli, you do not need to specify the number of KEYS, but you need to separate the KEYS and ARGV parameters with a comma, leaving at least 1 space before and after the comma, otherwise redis-cli-a password-- eval. / sadd_script.lua subjects, mathredis-cli-a password-- eval. / sadd_script.lua subjects, history

Define the business code you need in the lua script, demo:

Local setName = KEYS [1] local setValue = ARGV [1] if string.len (setName) > 0 and string.len (setValue) > 0then return redis.call ('sadd', setName, setValue) else return 0end3, php code:

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

Development

Wechat

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

12
Report