Complete the code to add a user with a score to the leaderboard.
ZADD leaderboard [1] user123The ZADD command requires the score before the member name. Here, 1500 is the score for user123.
Complete the code to get the top 3 users from the leaderboard.
ZREVRANGE leaderboard 0 [1] WITHSCORES
The ZREVRANGE command uses zero-based indexes. To get the top 3 users, use 0 to 2.
Fix the error in the code to increment a user's score by 50.
ZINCRBY leaderboard [1] user123The ZINCRBY command syntax is ZINCRBY key increment member. The increment value 50 must be the second argument.
Fill both blanks to remove a user from the leaderboard and then check if the user still exists.
ZREM leaderboard [1] ZSCORE leaderboard [2]
ZREM removes the member user123 from the leaderboard. Then ZSCORE checks the score of user123 to confirm removal.
Fill all three blanks to create a leaderboard, add two users, and get the rank of one user.
ZADD [1] 1000 [2] 1500 [3] ZRANK [1] [2]
The leaderboard is named leaderboard. We add userA with score 1000 and userB with 1500. Then we get the rank of userA in the leaderboard.