Redis › Lua Scripting
How do you pass keys and other arguments into a Lua script when executing it with the EVAL command?
BeginnerAnswer
You specify the actual key names as a group after the script text, preceded by a count of how many keys you are passing, followed by any additional argument values, and within the script itself you access these using the KEYS and ARGV tables, which is the recommended way to reference keys so Redis Cluster can correctly route the script to the right node.
EVAL "return redis.call('set', KEYS[1], ARGV[1])" 1 'mykey' 'myvalue'Real-world example A rate limiting script receives the specific key to check as KEYS[1] and the maximum allowed requests as ARGV[1], keeping the script generic and reusable across many different rate limited resources.