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?✗ Incorrect
ZADD adds members with scores to sorted sets only.
What happens if you use
ZADD to add a member that already exists with a different score?✗ Incorrect
The existing member's score is updated to the new score.
Which of these is the correct syntax to add two members with scores to a sorted set named
game?✗ Incorrect
The correct syntax is ZADD key score1 member1 score2 member2.
What does
ZADD return after adding members?✗ Incorrect
ZADD returns how many new members were added, excluding updated ones.
If you want to add a member with score 5 to a sorted set called
scores, which command is correct?✗ Incorrect
The score comes before the member name in the ZADD command.
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.