Skip to content

Commit

Permalink
Add ZCOUNT.
Browse files Browse the repository at this point in the history
  • Loading branch information
djanowski committed Jul 13, 2010
1 parent 8fa2151 commit 1dcf6a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/redis.rb
Expand Up @@ -284,6 +284,10 @@ def zrangebyscore(key, min, max, options = {})
@client.call(:zrangebyscore, key, min, max, *command.to_a)
end

def zcount(key, start, stop)
@client.call(:zcount, key, start, stop)
end

def zrevrange(key, start, stop, options = {})
command = CommandOptions.new(options) do |c|
c.bool :with_scores
Expand Down
8 changes: 8 additions & 0 deletions test/redis_test.rb
Expand Up @@ -898,6 +898,14 @@ class RedisTest < Test::Unit::TestCase
assert_equal ["s3", "3"], @r.zrangebyscore("foo", 2, 4, :limit => [1, 1], :with_scores => true)
end

test "ZCOUNT" do
@r.zadd "foo", 1, "s1"
@r.zadd "foo", 2, "s2"
@r.zadd "foo", 3, "s3"

assert_equal 2, @r.zcount("foo", 2, 3)
end

test "ZCARD" do
assert_equal 0, @r.zcard("foo")

Expand Down

0 comments on commit 1dcf6a8

Please sign in to comment.