Challenge - 5 Problems
Redis Hash Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of HGETALL on a hash with multiple fields?
Given a Redis hash stored as
HSET user:1 name "Alice" age "30" city "Paris", what will HGETALL user:1 return?Redis
HSET user:1 name "Alice" age "30" city "Paris" HGETALL user:1
Attempts:
2 left
💡 Hint
HGETALL returns a flat list of field and value pairs.
✗ Incorrect
HGETALL returns an array of strings representing alternating fields and their values in the hash. It does not return a dictionary or include the key name.
🧠 Conceptual
intermediate1:30remaining
Understanding HGETALL output format
Why does
HGETALL return a flat list of fields and values instead of a dictionary?Attempts:
2 left
💡 Hint
Think about how Redis communicates data over the network.
✗ Incorrect
Redis protocol returns arrays of strings. The client interprets the alternating elements as field and value pairs to reconstruct the hash.
📝 Syntax
advanced1:00remaining
Which command correctly retrieves all fields and values from a Redis hash?
Select the correct Redis command to get all fields and values from the hash key
session:123.Attempts:
2 left
💡 Hint
Only one command is the official Redis command for this purpose.
✗ Incorrect
HGETALL is the Redis command that returns all fields and values of a hash. GETALL and HMGET are invalid or incomplete commands.
❓ optimization
advanced2:00remaining
Optimizing retrieval of specific fields vs all fields
You want to retrieve only the fields
name and email from a large Redis hash user:1000. Which approach is more efficient?Attempts:
2 left
💡 Hint
Fetching only needed data reduces network and processing load.
✗ Incorrect
HMGET fetches only specified fields, reducing data transfer and client filtering compared to HGETALL.
🔧 Debug
expert2:30remaining
Why does HGETALL return an empty list?
You run
HGETALL order:500 but get an empty list []. What is the most likely reason?Attempts:
2 left
💡 Hint
Check if the key exists and its data type.
✗ Incorrect
If the key does not exist or is not a hash, HGETALL returns an empty list. It does not accept patterns.