Method: Redis#zcount

Defined in:
lib/redis.rb

#zcount(key, min, max) ⇒ Fixnum

Count the members in a sorted set with scores within the given values.

Examples:

Count members with score >= 5 and < 100

redis.zcount("zset", "5", "(100")
  # => 2

Count members with scores > 5

redis.zcount("zset", "(5", "+inf")
  # => 2

Parameters:

  • key (String)
  • min (String)
    • inclusive minimum score is specified verbatim
    • exclusive minimum score is specified by prefixing (
  • max (String)
    • inclusive maximum score is specified verbatim
    • exclusive maximum score is specified by prefixing (

Returns:

  • (Fixnum)

    number of members in within the specified range



1708
1709
1710
1711
1712
# File 'lib/redis.rb', line 1708

def zcount(key, min, max)
  synchronize do |client|
    client.call([:zcount, key, min, max])
  end
end