0
0
Redisquery~20 mins

HKEYS and HVALS 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
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
A["name", "age", "city"]
B["Alice", "30", "Paris"]
C["user:1"]
D[]
Attempts:
2 left
💡 Hint
HKEYS returns all the field names (keys) inside the hash.
query_result
intermediate
1: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
A["19.99", "50", "books"]
B["price", "stock", "category"]
C["product:100"]
D[]
Attempts:
2 left
💡 Hint
HVALS returns all the values inside the hash fields.
🧠 Conceptual
advanced
1:30remaining
Difference between HKEYS and HVALS
Which statement correctly describes the difference between HKEYS and HVALS in Redis?
A<code>HKEYS</code> returns all keys in Redis; <code>HVALS</code> returns all values in Redis.
B<code>HKEYS</code> returns all field values; <code>HVALS</code> returns all field names.
C<code>HKEYS</code> returns all field names; <code>HVALS</code> returns all field values.
D<code>HKEYS</code> returns the hash key; <code>HVALS</code> returns the hash size.
Attempts:
2 left
💡 Hint
Think about what each command returns from inside the hash.
📝 Syntax
advanced
1:00remaining
Identify the syntax error
Which of the following Redis commands will cause a syntax error?
AHVALS product:100
BHKEYS
CHKEYS user:1
DHVALS orders:2023
Attempts:
2 left
💡 Hint
Check if the command has the required arguments.
optimization
expert
2: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?
AHKEYS session:123
BHVALS session:123
CHMGET session:123 *
DHGETALL session:123
Attempts:
2 left
💡 Hint
Think about a command that returns both keys and values together.