Redis Zscore Command

Redis Sorted Set

The Redis Zscore command returns the score value of a member in a sorted set. If the member element is not a member of the sorted set key, or the key does not exist, nil is returned.

Syntax

The basic syntax of the Redis Zscore command is as follows:

redis 127.0.0.1:6379> ZSCORE key member

Available versions

>= 1.2.0

Return value

The score value of the member, expressed as a string.

Example

redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES    # 测试数据
1) "tom"
2) "2000"
3) "peter"
4) "3500"
5) "jack"
6) "5000"

redis 127.0.0.1:6379> ZSCORE salary peter              # 注意返回值是字符串
"3500"

Redis Sorted Set

Other extensions