summaryrefslogtreecommitdiff
path: root/redis
diff options
context:
space:
mode:
Diffstat (limited to 'redis')
-rwxr-xr-x[-rw-r--r--]redis/old_client.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/redis/old_client.py b/redis/old_client.py
index dcccdb8..fc56f62 100644..100755
--- a/redis/old_client.py
+++ b/redis/old_client.py
@@ -1059,7 +1059,7 @@ class Redis(object):
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')
@@ -1073,9 +1073,20 @@ class Redis(object):
1
>>> r.zrangebyscore('z1', 5, 7)
[u'a', u'c']
+ >>> r.zadd('z1', 'e', 8)
+ 1
+ >>> r.zrangebyscore('z1', 5, 8, offset=0, count=2)
+ [u'a', u'c']
+ >>> r.zrangebyscore('z1', 5, 8, offset=1, count=2)
+ [u'c', u'e']
"""
- 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):