0
0
Redisquery~15 mins

ZSCORE for member score in Redis - Mini Project: Build & Apply

Choose your learning style9 modes available
Using ZSCORE to Find Member Scores in Redis Sorted Sets
📖 Scenario: You are managing a leaderboard for a gaming app. Players have scores stored in a Redis sorted set. You want to find the exact score of a specific player using Redis commands.
🎯 Goal: Build a Redis command sequence that creates a sorted set with player scores, sets a player name to look up, and uses ZSCORE to find that player's score.
📋 What You'll Learn
Create a sorted set called game_leaderboard with these exact members and scores: "Alice" 1500, "Bob" 1200, "Charlie" 1800
Create a variable called player and set it to the string "Bob"
Use the ZSCORE command with game_leaderboard and player to get Bob's score
Store the result in a variable called bob_score
💡 Why This Matters
🌍 Real World
Leaderboards in games, ranking systems, and real-time scoring applications often use Redis sorted sets to store and retrieve scores efficiently.
💼 Career
Knowing how to use Redis sorted sets and commands like ZSCORE is valuable for backend developers working on performance-critical applications involving rankings or scoring.
Progress0 / 4 steps
1
Create the sorted set with player scores
Create a Redis sorted set called game_leaderboard with these exact members and scores: "Alice" 1500, "Bob" 1200, and "Charlie" 1800 using the ZADD command.
Redis
Need a hint?

Use ZADD followed by the sorted set name, then pairs of score and member.

2
Set the player variable to look up
Create a variable called player and set it to the string "Bob".
Redis
Need a hint?

Assign the string "Bob" to the variable player.

3
Use ZSCORE to get the player's score
Use the ZSCORE command with the sorted set game_leaderboard and the variable player to get Bob's score.
Redis
Need a hint?

Use ZSCORE with the sorted set name and the player variable, and assign the result to bob_score.

4
Complete by confirming the score variable
Ensure the variable bob_score holds the score retrieved by ZSCORE for player from game_leaderboard.
Redis
Need a hint?

Make sure bob_score is assigned the result of ZSCORE game_leaderboard Bob.