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

Redis Zcount Command

Redis Zcount Command

Redis Sorted Set

The Redis Zcount command is used to count the number of members in the sorted set within the specified score range.

Syntax

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



redis 127.0.0.1:6379> ZCOUNT key min max

Available Version

= 2.0.0

Return Value

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

Example



redis 127.0.0.1:6379> ZADD myzset 1 "hello"

(integer) 1

redis 127.0.0.1:6379> ZADD myzset 1 "foo"

(integer) 1

redis 127.0.0.1:6379> ZADD myzset 2 "world" 3 "bar"

(integer) 2

redis 127.0.0.1:6379> ZCOUNT myzset 1 3

(integer) 4

Redis Sorted Set