All quizzesMedium
Hashes, Lists & Sorted Sets — Series 2
Preview — 3 of 10 questions
What does SDIFF set1 set2 return, given set1 = {a, b, c} and set2 = {b, c, d}?
A{a}
B{d}
C{b, c}
D{a, b, c, d}
Which command retrieves all leaderboard members with a score between 1000 and 2000 (inclusive)?
AZSCORE leaderboard 1000 2000
BZRANGEBYSCORE leaderboard 1000 2000
CZRANGE leaderboard 1000 2000
DZFILTER leaderboard BETWEEN 1000 2000
A user just scored 50 more points. Which command correctly and atomically adds 50 to their existing leaderboard score?
AZSCORE leaderboard alice then ZADD leaderboard <old+50> alice — read-modify-write in application code
BZADD leaderboard INCR alice 50 — argument order is score then member, always
CZINCRBY leaderboard 50 alice — atomically adds 50 to alice's current score (creating alice with score 50 if she wasn't already a member), avoiding the race condition of a separate read-then-write
DSorted sets do not support incrementing; the member must be removed and re-added with the new total
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.