0
0
Redisquery~20 mins

HMSET and HMGET for bulk 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
2:00remaining
What is the output of this HMGET command?
Given the following Redis commands:

HMSET user:1 name "Alice" age "30" city "Paris"
HMGET user:1 name city

What is the output of the HMGET command?
Redis
HMSET user:1 name "Alice" age "30" city "Paris"
HMGET user:1 name city
A["Alice", null]
B["Alice", "Paris"]
C["name", "city"]
D["30", "Paris"]
Attempts:
2 left
💡 Hint
HMGET returns the values of the specified fields in the order requested.
📝 Syntax
intermediate
1:30remaining
Which HMSET command is syntactically correct?
Choose the correct syntax for setting multiple fields in a Redis hash with HMSET for key 'user:2' with fields 'name' as 'Bob' and 'age' as '25'.
AHMSET user:2 name Bob age 25
BHMSET user:2 {name: Bob, age: 25}
CHMSET user:2 [name Bob age 25]
DHMSET user:2 (name Bob, age 25)
Attempts:
2 left
💡 Hint
HMSET expects key followed by field and value pairs separated by spaces.
optimization
advanced
2:00remaining
Which approach is best to retrieve multiple fields efficiently?
You want to get the values of fields 'name', 'age', 'city', and 'email' from a Redis hash 'user:3'. Which command is the most efficient to retrieve all these fields at once?
AHGETALL user:3
B
HGET user:3 name
HGET user:3 age
HGET user:3 city
HGET user:3 email
CGET user:3
DHMGET user:3 name age city email
Attempts:
2 left
💡 Hint
HMGET retrieves multiple specified fields in one command.
🔧 Debug
advanced
2:00remaining
Why does this HMGET command return null for one field?
Given these commands:

HMSET user:4 name "Eve" age "28"
HMGET user:4 name city

Why does the HMGET command return ["Eve", null]?
Redis
HMSET user:4 name "Eve" age "28"
HMGET user:4 name city
AThe field 'city' does not exist in the hash, so HMGET returns null for it.
BThe HMGET command syntax is incorrect, causing null to be returned.
CRedis hashes cannot store more than two fields, so 'city' is ignored.
DThe HMSET command failed to set any fields, so all values are null.
Attempts:
2 left
💡 Hint
HMGET returns null for fields that do not exist in the hash.
🧠 Conceptual
expert
2:30remaining
What is the main difference between HMSET and HSET in recent Redis versions?
Redis introduced HSET to replace HMSET. What is the key difference between HMSET and HSET when setting multiple fields in a hash?
AHMSET supports setting fields with expiration, HSET does not.
BHMSET can set multiple fields but HSET can only set one field at a time.
CHSET can set multiple fields at once and HMSET is deprecated but both behave similarly.
DHSET requires JSON format for fields, HMSET uses plain key-value pairs.
Attempts:
2 left
💡 Hint
Check Redis documentation about HMSET deprecation and HSET enhancements.