English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Zcount Command

Redis Sorted Sets (sorted set)

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

Syntax

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.

Online Examples

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 Sets (sorted set)