Easy Tutorial
❮ Server Command Count Server Monitor ❯

Redis Zcount Command

Redis Sorted Set

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

Syntax

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

redis 127.0.0.1:6379> ZCOUNT key min max

Available Versions

= 2.0.0

Return Value

The number of members with scores 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

❮ Server Command Count Server Monitor ❯