Skip to content

Commit

Permalink
added offset & count parameters to zrangebyscore()
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Charnock committed Jan 15, 2010
1 parent 0fb0324 commit 30980d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def zrange(self, key, start, end, desc=False):
return self.send_command('%s %s %s %s\r\n' \
% (command, key, start, end))

def zrangebyscore(self, key, min, max):
def zrangebyscore(self, key, min, max, offset=None, count=None):
"""
>>> r = Redis(db=9)
>>> res = r.delete('z1')
Expand All @@ -1070,8 +1070,13 @@ def zrangebyscore(self, key, min, max):
>>> r.zrangebyscore('z1', 5, 7)
[u'a', u'c']
"""
return self.send_command('ZRANGEBYSCORE %s %s %s\r\n' % (
key, min, max
if offset is not None and count is not None:
limit = " LIMIT %d %d" % (offset, count)
else:
limit = ""

return self.send_command('ZRANGEBYSCORE %s %s %s%s\r\n' % (
key, min, max, limit
))

def zcard(self, key):
Expand Down

0 comments on commit 30980d3

Please sign in to comment.