Challenge - 5 Problems
Redis Memory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this Redis command sequence?
Consider the following Redis commands executed in order:
What is the output of
HMSET user:1 name "Alice" age 30 city "NY"HGETALL user:1What is the output of
HGETALL user:1?Redis
HMSET user:1 name "Alice" age 30 city "NY" HGETALL user:1
Attempts:
2 left
💡 Hint
Remember that HGETALL returns a flat list of fields and values as strings.
✗ Incorrect
The HGETALL command returns a flat list of field-value pairs as strings, not a JSON object or dictionary.
🧠 Conceptual
intermediate2:00remaining
Which Redis data structure is most memory-efficient for storing a large set of unique integers?
You need to store millions of unique integers in Redis with minimal memory usage. Which data structure should you choose?
Attempts:
2 left
💡 Hint
Think about bit-level storage for integers.
✗ Incorrect
Redis Bitmaps use bits to represent presence or absence of integers, making them very memory-efficient for large sets of integers.
📝 Syntax
advanced2:00remaining
Which Redis command correctly creates a memory-efficient small hash?
You want to create a small hash with fields 'a' and 'b' having values '1' and '2' respectively, optimized for memory. Which command is correct?
Attempts:
2 left
💡 Hint
Check the correct syntax for HSET with multiple fields.
✗ Incorrect
HSET supports multiple field-value pairs as separate arguments. HMSET is deprecated. Options A and D have invalid syntax.
❓ optimization
advanced2:00remaining
How to optimize memory usage for a Redis list with many small elements?
You have a Redis list with many small string elements. Which approach reduces memory usage the most?
Attempts:
2 left
💡 Hint
Redis uses special encodings for small lists to save memory.
✗ Incorrect
Redis automatically uses Ziplist encoding for small lists, which is memory efficient. Keeping the list small enables this optimization.
🔧 Debug
expert2:00remaining
Why does this Redis command cause a memory spike?
You run:
and notice a sudden memory spike. What is the most likely cause?
LPUSH mylist "a" "b" "c" ... "z"and notice a sudden memory spike. What is the most likely cause?
Redis
LPUSH mylist "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
Attempts:
2 left
💡 Hint
Redis changes internal encoding based on list size.
✗ Incorrect
When a list grows beyond a threshold, Redis switches from Ziplist (compact) to Linkedlist encoding, increasing memory usage.