0
0
Redisquery~3 mins

ZSCORE for member score in Redis

Choose your learning style9 modes available
Introduction
ZSCORE helps you find the score of a specific member in a sorted set. It tells you the exact value assigned to that member.
You want to check a player's points in a game leaderboard.
You need to find the rating of a product in a sorted list.
You want to see the priority score of a task in a queue.
You want to verify the score of a user in a ranking system.
Syntax
Redis
ZSCORE key member
The key is the name of the sorted set.
The member is the item whose score you want to find.
Examples
Get the score of 'player1' from the 'leaderboard' sorted set.
Redis
ZSCORE leaderboard player1
Find the score of 'task42' in the 'tasks' sorted set.
Redis
ZSCORE tasks task42
Sample Program
Add two players with scores to 'leaderboard' and get the score of 'player1'.
Redis
ZADD leaderboard 100 player1
ZADD leaderboard 200 player2
ZSCORE leaderboard player1
OutputSuccess
Important Notes
If the member does not exist, ZSCORE returns nil (no value).
Scores are stored as floating point numbers, but often used as integers.
ZSCORE only works with sorted sets, not regular sets or lists.
Summary
ZSCORE gets the score of a member in a sorted set.
Use it to check rankings or priorities easily.
It returns nil if the member is not found.