Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Zscore command

Redis Zscore command

Redis Sorted Set

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

Syntax

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



redis 127.0.0.1:6379> ZSCORE key member

Available Version

= 1.2.0

Return Value

The score of the member, represented 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