Recall & Review
beginner
What is the purpose of KEYS and ARGV in a Redis Lua script?
KEYS holds the list of keys passed to the script, while ARGV holds the list of additional arguments. They let the script access keys and parameters separately.Click to reveal answer
beginner
How do you access the first key inside a Redis Lua script?
Use KEYS[1] to get the first key passed to the script.
Click to reveal answer
beginner
How do you access the second argument inside a Redis Lua script?
Use ARGV[2] to get the second argument passed to the script.
Click to reveal answer
intermediate
Why separate keys and arguments in Redis Lua scripts?
Separating keys and arguments helps Redis know which keys the script will access, improving safety and performance.
Click to reveal answer
intermediate
What happens if you try to access a key index that was not passed to the script?
Accessing a key index that was not passed returns nil, meaning no key exists at that position.
Click to reveal answer
In a Redis Lua script, how do you access the third key passed to the script?
✗ Incorrect
KEYS is a table containing all keys passed. KEYS[3] accesses the third key.
Which variable holds the additional arguments passed to a Redis Lua script?
✗ Incorrect
ARGV holds the list of additional arguments passed to the script.
What will KEYS[1] return if no keys were passed to the script?
✗ Incorrect
If no keys are passed, KEYS[1] returns nil, meaning no value.
Why does Redis require keys to be passed separately from arguments in Lua scripts?
✗ Incorrect
Redis tracks keys separately to ensure scripts only access declared keys, improving safety and performance.
How do you access the first argument (not key) passed to a Redis Lua script?
✗ Incorrect
ARGV[1] accesses the first argument passed to the script.
Explain how to access keys and arguments inside a Redis Lua script and why they are separated.
Think about how Redis manages keys and extra data separately.
You got /3 concepts.
Describe what happens if you try to access a key or argument index that was not passed to the Redis Lua script.
Consider what Lua returns when accessing missing table elements.
You got /3 concepts.