0
0
Redisquery~20 mins

Memory-efficient data structures in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Memory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this Redis command sequence?
Consider the following Redis commands executed in order:

HMSET user:1 name "Alice" age 30 city "NY"
HGETALL user:1

What is the output of HGETALL user:1?
Redis
HMSET user:1 name "Alice" age 30 city "NY"
HGETALL user:1
A["user:1", "name", "Alice", "age", "30", "city", "NY"]
B{"name": "Alice", "age": 30, "city": "NY"}
C["name", "Alice", "age", "30", "city", "NY"]
D["name", "Alice", "age", 30, "city", "NY"]
Attempts:
2 left
💡 Hint
Remember that HGETALL returns a flat list of fields and values as strings.
🧠 Conceptual
intermediate
2: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?
ARedis Bitmap
BRedis Sorted Set
CRedis Set
DRedis List
Attempts:
2 left
💡 Hint
Think about bit-level storage for integers.
📝 Syntax
advanced
2: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?
AHSET myhash {a 1} {b 2}
BHSET myhash a 1 b 2
CHMSET myhash a 1 b 2
DHSET myhash a=1 b=2
Attempts:
2 left
💡 Hint
Check the correct syntax for HSET with multiple fields.
optimization
advanced
2: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?
AUse a Redis List as is
BUse Redis Sorted Set instead
CStore elements as separate keys
DConvert the list to a Redis Ziplist-encoded list by keeping it small
Attempts:
2 left
💡 Hint
Redis uses special encodings for small lists to save memory.
🔧 Debug
expert
2:00remaining
Why does this Redis command cause a memory spike?
You run:
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"
ARedis converted the list from Ziplist to Linkedlist due to size
BLPUSH command syntax is incorrect causing memory leak
CRedis is duplicating the list elements internally
DRedis is compressing the list causing temporary memory spike
Attempts:
2 left
💡 Hint
Redis changes internal encoding based on list size.