0
0
Redisquery~20 mins

Script loading and caching in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Script Caching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of SCRIPT LOAD command
What does the SCRIPT LOAD command return when you load a Lua script into Redis?
Redis
SCRIPT LOAD "return redis.call('PING')"
AAn integer representing the number of commands in the script
BA SHA1 hash string representing the loaded script
CThe output of the script execution, e.g., 'PONG'
DThe string 'OK' indicating the script loaded successfully
Attempts:
2 left
💡 Hint
Think about what Redis returns to identify a script uniquely after loading.
query_result
intermediate
2:00remaining
Result of EVALSHA with missing script
What happens when you run EVALSHA with a SHA1 hash that is not loaded in Redis?
Redis
EVALSHA <nonexistent_sha1> 0
ARedis returns an error indicating the script is not found
BRedis automatically loads the script from the last executed scripts
CRedis returns nil without error
DRedis executes the script anyway by fetching it from disk
Attempts:
2 left
💡 Hint
Consider what Redis does if the script hash is unknown.
📝 Syntax
advanced
2:00remaining
Identify the correct SCRIPT FLUSH usage
Which of the following commands correctly flushes all cached Lua scripts in Redis?
ASCRIPT DELETE ALL
BSCRIPT CLEAR
CSCRIPT FLUSH
DSCRIPT REMOVE
Attempts:
2 left
💡 Hint
Check the official Redis command for clearing scripts.
optimization
advanced
2:00remaining
Best practice for script execution performance
To optimize performance when running the same Lua script multiple times in Redis, which approach is best?
AUse MULTI/EXEC transactions to run the script multiple times
BRun the script each time with EVAL to avoid caching issues
CStore the script in a Redis key and retrieve it before each execution
DLoad the script once with SCRIPT LOAD, then run it multiple times with EVALSHA
Attempts:
2 left
💡 Hint
Think about how Redis caches scripts and how to reuse them efficiently.
🧠 Conceptual
expert
2:00remaining
Understanding script caching behavior on Redis restart
What happens to cached Lua scripts in Redis after a server restart?
AAll cached scripts are lost and must be reloaded
BCached scripts persist automatically across restarts
CScripts are saved to disk and reloaded on startup
DScripts remain cached if Redis is configured with AOF persistence
Attempts:
2 left
💡 Hint
Consider Redis memory and persistence behavior for scripts.