count

英[kaʊnt] 美[kaʊnt]

n.Total number; Count; Count; Arguments

v. Count ;Calculate the total; count...;Important

Third person singular: counts Plural: counts Present participle: counting Past tense: counted Past participle: counted

redis ZCOUNT command syntax

Function:Returns the number of members in the ordered set key whose score value is between min and max (the default includes score value equal to min or max).

Syntax: ZCOUNT key min max

Available versions:>= 2.0.0

Time complexity Degree: O(log(N) M), N is the cardinality of the ordered set, M is the number of elements with values ​​between min and max.

Return: The number of members whose score value is between min and max.

redis ZCOUNT command example

redis> ZRANGE salary 0 -1 WITHSCORES    # 测试数据
1) "jack"
2) "2000"
3) "peter"
4) "3500"
5) "tom"
6) "5000"
redis> ZCOUNT salary 2000 5000          # 计算薪水在 2000-5000 之间的人数
(integer) 3
redis> ZCOUNT salary 3000 5000          # 计算薪水在 3000-5000 之间的人数
(integer) 2