0
0
Redisquery~20 mins

Object storage with hashes in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Hash Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
Retrieve a field from a Redis hash
Given a Redis hash stored with key user:1001 containing fields name, email, and age, what is the output of the command HGET user:1001 email if the stored email is alice@example.com?
Redis
HSET user:1001 name Alice email alice@example.com age 30
HGET user:1001 email
A"alice@example.com"
B"Alice"
C30
Dnil
Attempts:
2 left
💡 Hint
Remember that HGET returns the value of the specified field in the hash.
📝 Syntax
intermediate
1:30remaining
Identify the correct Redis command to add multiple fields to a hash
Which of the following commands correctly adds multiple fields title and author to a Redis hash with key book:1?
AHMSET book:1 title "Redis Basics" author "John Doe"
BHADD book:1 title "Redis Basics" author "John Doe"
CHSET book:1 {title: "Redis Basics", author: "John Doe"}
DHSET book:1 title "Redis Basics" author "John Doe"
Attempts:
2 left
💡 Hint
Use the modern command that supports multiple field-value pairs.
optimization
advanced
2:00remaining
Efficiently retrieving multiple fields from a Redis hash
You want to retrieve the fields name, email, and age from a Redis hash user:1002. Which command is the most efficient to get all three fields in a single call?
AHMGET user:1002 name email age
BHGETALL user:1002
C
HGET user:1002 name
HGET user:1002 email
HGET user:1002 age
DGET user:1002
Attempts:
2 left
💡 Hint
Choose the command that fetches specific fields in one request.
🔧 Debug
advanced
1:30remaining
Identify the error in this Redis hash command
What error will the following Redis command produce?
HSET user:1003 name "Bob" age
Redis
HSET user:1003 name "Bob" age
ASets 'age' field to the string 'age'
BSets 'age' field to empty string
CSyntax error: wrong number of arguments for 'HSET' command
DNo error, command runs successfully
Attempts:
2 left
💡 Hint
HSET requires field-value pairs; check if all pairs are complete.
🧠 Conceptual
expert
2:30remaining
Understanding Redis hash memory efficiency
Why are Redis hashes considered memory efficient for storing many small objects compared to storing each object as a separate key?
ABecause hashes allow storing only string values, which are smaller
BBecause hashes internally use a ziplist or hashtable optimized for small fields, reducing overhead per field
CBecause hashes store data on disk instead of memory
DBecause Redis compresses all hash keys automatically
Attempts:
2 left
💡 Hint
Think about how Redis stores small hashes internally.