YouTip LogoYouTip

Sorted Sets Zcount

Redis Zcount Command | Novice Tutorial

Novice Tutorial -- Learning Not Just Technology, But Dreams!

Redis Tutorial Redis TutorialRedis IntroductionRedis InstallationRedis ConfigurationRedis Data Types

Redis Commands

Redis CommandsRedis KeysRedis StringsRedis HashRedis ListRedis SetRedis Sorted SetRedis HyperLogLogRedis Publish SubscribeRedis TransactionsRedis ScriptingRedis ConnectionRedis ServerRedis GEORedis Stream

Redis Advanced Tutorial

Redis Data Backup and RecoveryRedis SecurityRedis Performance TestingRedis Client ConnectionRedis PipeliningRedis PartitioningJava Using RedisPHP Using Redis Redis Zcard CommandRedis Zcard Command Redis Zincrby CommandRedis Zincrby Command

Redis Zcount Command

Redis Sorted Set The Redis Zcount command is used to calculate the number of members in a sorted set within a 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 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
← Sorted Sets ZincrbySorted Sets Zcard β†’