0
0
Redisquery~20 mins

SADD and SREM for membership in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What is the result of adding members with SADD?
You have an empty Redis set named fruits. You run the command SADD fruits apple banana apple. What is the return value of this command?
Redis
SADD fruits apple banana apple
A3
B2
C1
D0
Attempts:
2 left
💡 Hint
SADD adds only unique members and returns the number of new elements added.
query_result
intermediate
1:30remaining
What happens when removing members with SREM?
Given a Redis set colors containing {red, green, blue}, what does the command SREM colors green yellow return?
Redis
SREM colors green yellow
A3
B2
C0
D1
Attempts:
2 left
💡 Hint
SREM returns the number of members actually removed from the set.
📝 Syntax
advanced
1:30remaining
Which SADD command is syntactically correct?
Choose the correct syntax to add multiple members to a Redis set named pets:
ASADD pets [dog cat bird]
BSADD pets (dog, cat, bird)
CSADD pets dog cat bird
DSADD pets 'dog', 'cat', 'bird'
Attempts:
2 left
💡 Hint
Redis commands list members separated by spaces without brackets or quotes.
query_result
advanced
2:00remaining
What is the set content after SADD and SREM commands?
Starting with an empty set numbers, you run these commands in order:
1. SADD numbers 1 2 3 4
2. SREM numbers 2 5
3. SADD numbers 5 6
What members does the set numbers contain now?
Redis
SADD numbers 1 2 3 4
SREM numbers 2 5
SADD numbers 5 6
A{1, 3, 4, 5, 6}
B{1, 2, 3, 4, 5, 6}
C{1, 3, 4, 6}
D{2, 3, 4, 5, 6}
Attempts:
2 left
💡 Hint
Remember SREM removes only existing members; SADD adds unique members.
🧠 Conceptual
expert
2:00remaining
Why does SADD return 0 sometimes?
You run SADD animals dog cat on a set that already contains {dog, cat}. What does the return value 0 mean in this context?
ANo new members were added because all were already present
BThe command failed due to a syntax error
CThe set was deleted before the command ran
DThe command added zero members because the set is full
Attempts:
2 left
💡 Hint
SADD returns the count of new unique members added, not total members.