Challenge - 5 Problems
HEXISTS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
Check if a field exists in a Redis hash
Given a Redis hash named
user:1000 with fields name and email, what is the output of the command HEXISTS user:1000 email?Redis
HSET user:1000 name "Alice" email "alice@example.com"
Attempts:
2 left
💡 Hint
HEXISTS returns 1 if the field exists, otherwise 0.
✗ Incorrect
The HEXISTS command checks if a field exists in a hash. Since email is set, it returns 1.
❓ query_result
intermediate1:30remaining
Check non-existing field in Redis hash
What is the output of
HEXISTS user:1000 age if the hash user:1000 only contains fields name and email?Redis
HSET user:1000 name "Alice" email "alice@example.com"
Attempts:
2 left
💡 Hint
Check if the field is present or not.
✗ Incorrect
The field age does not exist in the hash, so HEXISTS returns 0.
📝 Syntax
advanced1:30remaining
Identify the correct HEXISTS command syntax
Which of the following commands correctly checks if the field
status exists in the hash order:123?Attempts:
2 left
💡 Hint
The syntax is HEXISTS key field
✗ Incorrect
The correct syntax is HEXISTS key field. Option A follows this format.
❓ query_result
advanced1:30remaining
HEXISTS behavior with non-hash key
What happens when you run
HEXISTS mykey field1 if mykey is a string key with value hello?Redis
SET mykey "hello"Attempts:
2 left
💡 Hint
HEXISTS only works on hashes.
✗ Incorrect
If the key is not a hash, Redis returns a type error when running HEXISTS.
🧠 Conceptual
expert2:00remaining
Using HEXISTS in conditional logic
You want to increment a numeric field
visits in a Redis hash page:home only if the field exists. Which Redis command sequence correctly achieves this?Attempts:
2 left
💡 Hint
Redis commands are atomic but do not support IF statements directly.
✗ Incorrect
Redis does not support IF statements in its command syntax. To conditionally increment a field only if it exists, you must use a Lua script that checks HEXISTS and then increments with HINCRBY atomically.