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 does HKEYS return?
Given a Redis hash stored as
HSET user:1 name "Alice" age "30" city "Paris", what is the output of HKEYS user:1?Redis
HSET user:1 name "Alice" age "30" city "Paris" HKEYS user:1
Attempts:
2 left
💡 Hint
HKEYS returns all the field names (keys) inside the hash.
✗ Incorrect
The HKEYS command returns a list of all the field names (keys) stored inside the hash. It does not return the values or the hash key itself.
❓ query_result
intermediate1:30remaining
What does HVALS return?
Given a Redis hash stored as
HSET product:100 price "19.99" stock "50" category "books", what is the output of HVALS product:100?Redis
HSET product:100 price "19.99" stock "50" category "books" HVALS product:100
Attempts:
2 left
💡 Hint
HVALS returns all the values inside the hash fields.
✗ Incorrect
The HVALS command returns a list of all the values stored inside the hash fields. It does not return the field names or the hash key.
🧠 Conceptual
advanced1:30remaining
Difference between HKEYS and HVALS
Which statement correctly describes the difference between
HKEYS and HVALS in Redis?Attempts:
2 left
💡 Hint
Think about what each command returns from inside the hash.
✗ Incorrect
HKEYS returns the field names (keys) inside a hash, while HVALS returns the values of those fields. They do not return the hash key or all keys in Redis.
📝 Syntax
advanced1:00remaining
Identify the syntax error
Which of the following Redis commands will cause a syntax error?
Attempts:
2 left
💡 Hint
Check if the command has the required arguments.
✗ Incorrect
Both HKEYS and HVALS require a key argument. Option B misses the key, causing a syntax error.
❓ optimization
expert2:00remaining
Efficiently retrieving all fields and values
You want to retrieve all fields and their values from a large Redis hash named
session:123. Which command is the most efficient to get both keys and values in one call?Attempts:
2 left
💡 Hint
Think about a command that returns both keys and values together.
✗ Incorrect
HGETALL returns all fields and their values in one call. HKEYS and HVALS return only keys or values separately. HMGET requires specific fields, not a wildcard.