Challenge - 5 Problems
Cache Warming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What is the main purpose of cache warming?
Why do we use cache warming in systems that use Redis or other caching layers?
Attempts:
2 left
💡 Hint
Think about how cache warming affects response times for users.
✗ Incorrect
Cache warming is used to load data into the cache ahead of time so that when users request it, the system can respond quickly without delay.
❓ query_result
intermediate2:00remaining
Which Redis command sequence best warms the cache for a list of keys?
Given a list of keys ['user:1', 'user:2', 'user:3'], which option correctly fetches and caches their values in Redis to warm the cache?
Redis
Assume a function fetchFromDB(key) returns the value for the key from the database.
Attempts:
2 left
💡 Hint
Warming means loading data into cache before requests.
✗ Incorrect
Option C fetches data from the database and stores it in Redis, effectively warming the cache.
📝 Syntax
advanced2:30remaining
Identify the correct Lua script snippet for warming cache in Redis
Which Lua script correctly sets multiple keys with their values in Redis for cache warming?
Redis
Keys and values are passed as KEYS and ARGV arrays respectively.
Attempts:
2 left
💡 Hint
Remember the length of KEYS and ARGV arrays and the SET command syntax.
✗ Incorrect
Option A correctly loops over KEYS and sets each key with the corresponding value from ARGV.
❓ optimization
advanced2:00remaining
Best strategy to warm cache for a large dataset efficiently
You need to warm cache for 10,000 user profiles in Redis. Which approach is most efficient?
Attempts:
2 left
💡 Hint
Think about network round trips and command batching.
✗ Incorrect
Pipelining reduces network overhead by sending many commands at once, speeding up cache warming.
🔧 Debug
expert3:00remaining
Why does this cache warming script fail to store all keys?
Given this Python snippet warming Redis cache:
import redis
r = redis.Redis()
keys = ['a', 'b', 'c']
values = ['1', '2', '3']
for i in range(len(keys)):
r.set(keys[i], values[i])
if i == 1:
raise Exception('Simulated error')
Why are only some keys cached?
Attempts:
2 left
💡 Hint
Look at the loop and where the error occurs.
✗ Incorrect
The exception interrupts the loop after setting the second key, so the last key is not cached.