0
0
Redisquery~5 mins

ZADD for adding scored members in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command ZADD do?
The ZADD command adds one or more members with scores to a sorted set in Redis. It keeps the set ordered by score.
Click to reveal answer
beginner
How do you add a member with score 10 to a sorted set named players using ZADD?
Use the command: ZADD players 10 member_name. This adds member_name with score 10 to the players sorted set.
Click to reveal answer
intermediate
What happens if you add a member that already exists in the sorted set with a new score using ZADD?
The member's score is updated to the new score you provide. The sorted set reorders itself based on the updated score.
Click to reveal answer
intermediate
Can ZADD add multiple members at once? How?
Yes. You can add multiple members by listing score-member pairs: ZADD key score1 member1 score2 member2 ....
Click to reveal answer
intermediate
What does the return value of ZADD represent?
It returns the number of new members added to the sorted set, not counting members whose scores were updated.
Click to reveal answer
What type of Redis data structure does ZADD work with?
AHashes
BLists
CSorted sets
DStrings
What happens if you use ZADD to add a member that already exists with a different score?
AThe member is ignored
BThe member's score is updated
CAn error is returned
DThe member is duplicated
Which of these is the correct syntax to add two members with scores to a sorted set named game?
AZADD game member1 10 member2 20
BZADD game 10 20 member1 member2
CZADD game member1 10, member2 20
DZADD game 10 member1 20 member2
What does ZADD return after adding members?
ANumber of new members added
BThe lowest score in the set
CThe highest score in the set
DTotal number of members in the set
If you want to add a member with score 5 to a sorted set called scores, which command is correct?
AZADD scores 5 member
BZADD scores member 5
CZADD scores 5:member
DZADD scores (5, member)
Explain how the ZADD command works in Redis and what it is used for.
Think about adding and ordering members by numbers.
You got /4 concepts.
    Describe the syntax of the ZADD command and how to add multiple members at once.
    Remember the order: score then member, repeated for each.
    You got /4 concepts.