Skip to main content

Method Signature

Parameters

key
string
required
The key of the sorted set
min
number | string
required
The minimum score in the range:
  • number - Inclusive minimum score
  • (number - Exclusive minimum score (e.g., (50 means greater than 50)
  • -inf - Negative infinity (all scores below max)
max
number | string
required
The maximum score in the range:
  • number - Inclusive maximum score
  • (number - Exclusive maximum score (e.g., (100 means less than 100)
  • +inf - Positive infinity (all scores above min)

Response

result
number
The number of members in the sorted set with scores in the specified range

Examples

Count members in a score range

Count with exclusive bounds

Count all scores above a threshold

Count all scores below a threshold

Count all members

Grade distribution analysis

Calculate percentile

Monitor score ranges

Price range filtering

Time-based analysis

Statistical analysis

  • ZCARD - Get the total number of members
  • ZRANGE - Return members in a range
  • ZSCORE - Get the score of a member
  • ZADD - Add members to a sorted set