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?✗ Incorrect
SREM removes specified members from a set if they exist.If you run
SADD myset a b c and 'a' and 'b' are already in 'myset', what does it return?✗ Incorrect
SADD returns the count of new members added. Only 'c' is new here.Which command checks if a member is in a Redis set?
✗ Incorrect
SISMEMBER returns 1 if the member exists, 0 otherwise.What does
SREM myset x y return if only 'x' is in 'myset'?✗ Incorrect
SREM returns the number of members removed. Only 'x' was removed.Can
SADD add duplicate members to a set?✗ Incorrect
Sets do not allow duplicates;
SADD ignores members already present.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.