0
0
Redisquery~5 mins

Accessing keys and arguments in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AKEYS[3]
BARGV[3]
CKEYS(3)
DARGV(3)
Which variable holds the additional arguments passed to a Redis Lua script?
AKEYS
BARGV
CARGS
DPARAMS
What will KEYS[1] return if no keys were passed to the script?
AAn empty string
BAn error
Cnil
D0
Why does Redis require keys to be passed separately from arguments in Lua scripts?
ATo allow Redis to track key usage for safety and performance
BTo enable multi-threading
CTo reduce script size
DTo improve script readability
How do you access the first argument (not key) passed to a Redis Lua script?
APARAMS[1]
BKEYS[1]
CARGS[1]
DARGV[1]
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.