0
0
Redisquery~10 mins

SISMEMBER for membership check in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - SISMEMBER for membership check
Start
Check if element exists in set
Yes No
Return 1
End
SISMEMBER checks if a given element is in a Redis set and returns 1 if yes, 0 if no.
Execution Sample
Redis
SADD fruits apple banana cherry
SISMEMBER fruits banana
SISMEMBER fruits orange
Add three fruits to a set, then check if 'banana' and 'orange' are members.
Execution Table
StepCommandSet ContentElement CheckedResultExplanation
1SADD fruits apple banana cherryapple, banana, cherry--Add elements to set 'fruits'
2SISMEMBER fruits bananaapple, banana, cherrybanana1'banana' is in the set, returns 1
3SISMEMBER fruits orangeapple, banana, cherryorange0'orange' not in set, returns 0
💡 All commands executed; membership checks returned 1 or 0 accordingly.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3
fruits setemptyapple, banana, cherryapple, banana, cherryapple, banana, cherry
SISMEMBER resultN/AN/A10
Key Moments - 2 Insights
Why does SISMEMBER return 1 for 'banana' but 0 for 'orange'?
Because 'banana' was added to the set in step 1 (see execution_table row 1), so SISMEMBER finds it and returns 1. 'orange' was never added, so it returns 0 (see row 3).
Does SISMEMBER change the set contents?
No, SISMEMBER only checks membership and does not modify the set. The set remains the same after membership checks (see variable_tracker for 'fruits set').
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the result of SISMEMBER checking 'banana'?
A-1
B0
C1
DError
💡 Hint
Check execution_table row 2 under 'Result' column.
At which step does the set 'fruits' get its elements added?
AStep 2
BStep 1
CStep 3
DNo step adds elements
💡 Hint
Look at execution_table row 1 where SADD command is executed.
If we check SISMEMBER for 'apple' after step 3, what would the result be?
A1
B0
CError
DDepends on previous commands
💡 Hint
Refer to variable_tracker showing 'apple' is in the set after step 1 and no changes after.
Concept Snapshot
SISMEMBER key element
- Checks if 'element' is in the set stored at 'key'
- Returns 1 if present, 0 if not
- Does not modify the set
- Useful for quick membership tests in Redis sets
Full Transcript
This visual execution shows how the Redis command SISMEMBER works. First, elements 'apple', 'banana', and 'cherry' are added to the set 'fruits' using SADD. Then, SISMEMBER checks if 'banana' is in the set and returns 1 because it is present. Next, it checks for 'orange' and returns 0 because 'orange' was never added. The set remains unchanged during membership checks. This helps understand how SISMEMBER quickly tells if an element is part of a Redis set without changing data.