0
0
Redisquery~5 mins

SADD and SREM for membership in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command SADD do?
The SADD command adds one or more members to a set stored at a key. If the members are already in the set, they are ignored.
Click to reveal answer
beginner
What happens if you use SREM on a member that is not in the set?
If the member is not in the set, SREM does nothing and returns 0, meaning no members were removed.
Click to reveal answer
intermediate
How can you check if a member exists in a Redis set?
Use the SISMEMBER command. It returns 1 if the member exists in the set, otherwise 0.
Click to reveal answer
beginner
Can SADD add multiple members at once? How?
Yes, SADD can add multiple members by listing them all after the key, separated by spaces.
Click to reveal answer
intermediate
What is the return value of SADD?
SADD returns the number of members that were actually added to the set, excluding those already present.
Click to reveal answer
What does the Redis command SREM myset member1 do?
AAdds 'member1' to the set 'myset'
BDeletes the entire set 'myset'
CChecks if 'member1' is in 'myset'
DRemoves 'member1' from the set 'myset' if it exists
If you run SADD myset a b c and 'a' and 'b' are already in 'myset', what does it return?
A0
B3
C1
D2
Which command checks if a member is in a Redis set?
ASISMEMBER
BSREM
CSADD
DSMEMBERS
What does SREM myset x y return if only 'x' is in 'myset'?
A2
B1
C0
DError
Can SADD add duplicate members to a set?
ANo, duplicates are ignored
BYes, duplicates are added
COnly if you use a special flag
DIt depends on the Redis version
Explain how SADD and SREM work for managing membership in Redis sets.
Think about adding and removing friends from a group.
You got /4 concepts.
    Describe how you would check if a member exists in a Redis set and then remove it if present.
    First check, then remove if found.
    You got /3 concepts.