Challenge - 5 Problems
Redis Hash Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the output of this Redis command sequence?
Consider the following Redis commands executed in order:
What will be the output of the
HSET user:1 name "Alice" age 30HGET user:1 nameWhat will be the output of the
HGET command?Redis
HSET user:1 name "Alice" age 30 HGET user:1 name
Attempts:
2 left
💡 Hint
HSET stores fields and values in a hash. HGET retrieves the value of a given field.
✗ Incorrect
The HSET command sets multiple fields in the hash 'user:1'. The field 'name' is set to 'Alice'. The HGET command retrieves the value of the 'name' field, which is 'Alice'.
❓ query_result
intermediate1:30remaining
What happens if you HGET a non-existing field?
Given the hash key
What is the result of:
user:2 with fields:HSET user:2 name "Bob"What is the result of:
HGET user:2 age?Redis
HSET user:2 name "Bob" HGET user:2 age
Attempts:
2 left
💡 Hint
HGET returns nil if the field does not exist in the hash.
✗ Incorrect
Since the field 'age' does not exist in the hash 'user:2', HGET returns nil to indicate no value.
📝 Syntax
advanced1:30remaining
Which command correctly sets multiple fields in a hash?
You want to set the fields 'name' to 'Carol' and 'age' to 25 in the hash 'user:3'. Which command is correct?
Attempts:
2 left
💡 Hint
HSET takes the key followed by field and value pairs as separate arguments.
✗ Incorrect
The correct syntax for HSET is: HSET key field1 value1 field2 value2 ... Option B follows this syntax exactly.
❓ optimization
advanced2:00remaining
Which approach is more efficient to update multiple fields in a Redis hash?
You need to update 5 fields in a Redis hash. Which is the best approach?
Attempts:
2 left
💡 Hint
Minimizing the number of commands sent to Redis improves performance.
✗ Incorrect
Using a single HSET command with all fields reduces network overhead and is more efficient than multiple commands.
🧠 Conceptual
expert2:00remaining
What is the result of this Redis command sequence?
Given the commands:
What is the output of the last command?
HSET user:4 name "Dave" age 40HSET user:4 age 41HGET user:4 ageWhat is the output of the last command?
Redis
HSET user:4 name "Dave" age 40 HSET user:4 age 41 HGET user:4 age
Attempts:
2 left
💡 Hint
HSET overwrites existing fields with new values.
✗ Incorrect
The second HSET updates the 'age' field to 41, so HGET returns "41".