Skip to content

Commit 30980d3

Browse files
author
Adam Charnock
committed
added offset & count parameters to zrangebyscore()
1 parent 0fb0324 commit 30980d3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

redis.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ def zrange(self, key, start, end, desc=False):
10551055
return self.send_command('%s %s %s %s\r\n' \
10561056
% (command, key, start, end))
10571057

1058-
def zrangebyscore(self, key, min, max):
1058+
def zrangebyscore(self, key, min, max, offset=None, count=None):
10591059
"""
10601060
>>> r = Redis(db=9)
10611061
>>> res = r.delete('z1')
@@ -1070,8 +1070,13 @@ def zrangebyscore(self, key, min, max):
10701070
>>> r.zrangebyscore('z1', 5, 7)
10711071
[u'a', u'c']
10721072
"""
1073-
return self.send_command('ZRANGEBYSCORE %s %s %s\r\n' % (
1074-
key, min, max
1073+
if offset is not None and count is not None:
1074+
limit = " LIMIT %d %d" % (offset, count)
1075+
else:
1076+
limit = ""
1077+
1078+
return self.send_command('ZRANGEBYSCORE %s %s %s%s\r\n' % (
1079+
key, min, max, limit
10751080
))
10761081

10771082
def zcard(self, key):

0 commit comments

Comments
 (0)