0
0
Redisquery~20 mins

Eviction policies overview in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Eviction Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Redis eviction policy: noeviction
What happens when Redis reaches its max memory limit and the eviction policy is set to noeviction?
ARedis increases its memory limit dynamically to accommodate new data.
BRedis removes the least recently used keys automatically to free memory.
CRedis removes random keys to free memory and continues accepting writes.
DRedis stops accepting writes and returns an error until memory is freed.
Attempts:
2 left
💡 Hint
Think about what 'no eviction' means for memory management.
query_result
intermediate
2:00remaining
Result of keys removed with allkeys-lru policy
Assume Redis has maxmemory set and eviction policy allkeys-lru. The database contains keys with varying last access times. Which keys will Redis remove first when memory is full?
ARandom keys without considering access time or expiration.
BOnly keys with an expiration time that are closest to expiring.
CKeys that were accessed least recently, regardless of expiration.
DKeys that were added most recently to the database.
Attempts:
2 left
💡 Hint
LRU means 'Least Recently Used'.
📝 Syntax
advanced
2:00remaining
Correct Redis config command for volatile-lfu eviction
Which Redis configuration command correctly sets the eviction policy to volatile-lfu?
ACONFIG SET maxmemory-policy volatile-lfu
BCONFIG SET eviction-policy volatile-lfu
CSET maxmemory-policy volatile-lfu
DCONFIG GET maxmemory volatile-lfu
Attempts:
2 left
💡 Hint
Check the exact syntax for setting maxmemory policy in Redis.
optimization
advanced
2:00remaining
Choosing eviction policy for frequently accessed keys with expiration
You have a Redis cache with many keys that have expiration times and are accessed frequently. You want to optimize memory usage by evicting keys that are least frequently used but only among keys with expiration set. Which eviction policy should you choose?
Aallkeys-lru
Bvolatile-lfu
Cvolatile-random
Dnoeviction
Attempts:
2 left
💡 Hint
Focus on eviction policies that consider frequency and expiration.
🔧 Debug
expert
2:00remaining
Why does Redis evict keys unexpectedly with allkeys-random?
A Redis instance is configured with maxmemory and eviction policy allkeys-random. Unexpectedly, keys that are still frequently accessed are being evicted. Why does this happen?
ABecause allkeys-random evicts keys randomly without considering usage or expiration.
BBecause Redis evicts keys based on least recently used order in allkeys-random.
CBecause the maxmemory setting is ignored when eviction policy is allkeys-random.
DBecause Redis evicts only expired keys first, ignoring the policy.
Attempts:
2 left
💡 Hint
Think about what 'random' means in eviction context.