Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis of redis script Command execution

Shulou Source: shulou.com Published: 2022-06-01 04:00:22 10月05日 Update

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:

Tags: Commands parameters scripts problems examples case analysis analysis knowledge differences code industry comma utility business content practicality actual quantity articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Docker macOS Shulou Technology