Challenge - 5 Problems
Redis SISMEMBER Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
Check if a member exists in a Redis set
Given a Redis set named
fruits containing apple, banana, and cherry, what is the output of SISMEMBER fruits banana?Redis
SISMEMBER fruits banana
Attempts:
2 left
💡 Hint
SISMEMBER returns 1 if the element is in the set, otherwise 0.
✗ Incorrect
The command SISMEMBER fruits banana checks if banana is a member of the set fruits. Since banana is in the set, it returns 1.
❓ query_result
intermediate1:30remaining
Check membership of a non-existing element
What is the output of
SISMEMBER fruits orange if the set fruits contains apple, banana, and cherry?Redis
SISMEMBER fruits orange
Attempts:
2 left
💡 Hint
SISMEMBER returns 0 if the element is not in the set.
✗ Incorrect
The command SISMEMBER fruits orange checks if orange is in the set fruits. Since it is not, the command returns 0.
📝 Syntax
advanced2:00remaining
Identify the syntax error in SISMEMBER usage
Which option shows an incorrect syntax for the SISMEMBER command?
Attempts:
2 left
💡 Hint
SISMEMBER requires exactly two arguments: the set key and the member to check.
✗ Incorrect
Option A is missing the member argument. The correct syntax is SISMEMBER <key> <member>. Without the member, Redis returns a syntax error.
❓ query_result
advanced1:30remaining
Check membership on a non-existing set
What is the output of
SISMEMBER colors red if the set colors does not exist in Redis?Redis
SISMEMBER colors red
Attempts:
2 left
💡 Hint
SISMEMBER returns 0 if the set does not exist.
✗ Incorrect
If the set colors does not exist, Redis treats it as an empty set. Checking membership returns 0 because red is not a member.
🧠 Conceptual
expert2:30remaining
Understanding SISMEMBER return values
Which statement correctly describes the return values of the Redis SISMEMBER command?
Attempts:
2 left
💡 Hint
Think about how Redis treats non-existing sets for membership checks.
✗ Incorrect
The SISMEMBER command returns 1 if the member is in the set, 0 if the member is not in the set, and also 0 if the set does not exist (treated as empty). It never returns nil or errors for non-existing sets.