0
0
Redisquery~20 mins

Maxmemory setting in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Maxmemory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What is the output of the command to check maxmemory?
You run the Redis command CONFIG GET maxmemory. What is the expected output format?
Redis
CONFIG GET maxmemory
A["maxmemory"]
B"maxmemory 0"
C["maxmemory", "0"]
D0
Attempts:
2 left
💡 Hint
Remember Redis returns configuration as an array with key and value.
🧠 Conceptual
intermediate
1:30remaining
What happens if maxmemory is set to 0 in Redis?
In Redis, if you set maxmemory to 0, what does it mean for memory usage?
ARedis has no memory limit and can use all available memory.
BRedis will limit memory usage to 0 bytes and refuse writes.
CRedis will use a default memory limit of 100MB.
DRedis will automatically evict keys when memory reaches 0.
Attempts:
2 left
💡 Hint
Think about what zero means as a limit.
📝 Syntax
advanced
2:00remaining
Which command correctly sets maxmemory to 100 megabytes?
Choose the correct Redis command to set maxmemory to 100MB.
ACONFIG SET maxmemory 100000000
BCONFIG SET maxmemory 100MB
CCONFIG SET maxmemory 100mb
DCONFIG SET maxmemory 104857600
Attempts:
2 left
💡 Hint
Redis expects maxmemory in bytes, not with units.
optimization
advanced
2:00remaining
How to configure Redis to evict least recently used keys when maxmemory is reached?
You want Redis to remove least recently used keys automatically when memory limit is reached. Which command sets this behavior?
ACONFIG SET maxmemory-policy volatile-lru
BCONFIG SET maxmemory-policy allkeys-lru
CCONFIG SET maxmemory-policy noeviction
DCONFIG SET maxmemory-policy allkeys-random
Attempts:
2 left
💡 Hint
Look for a policy that evicts any key based on usage.
🔧 Debug
expert
2:30remaining
Why does Redis not evict keys despite maxmemory being set and policy configured?
You set maxmemory to 50MB and maxmemory-policy to allkeys-lru, but Redis never evicts keys and memory usage grows beyond 50MB. What is the most likely cause?
AThe maxmemory-policy setting is ignored if maxmemory is zero or not set properly.
BEviction only happens if keys have expiration times set.
CRedis only evicts keys when memory usage reaches maxmemory plus a safety margin.
DThe maxmemory setting is not applied because Redis was not restarted.
Attempts:
2 left
💡 Hint
Check if maxmemory is properly set and non-zero.