summaryrefslogtreecommitdiff
path: root/redis/commands/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'redis/commands/core.py')
-rw-r--r--redis/commands/core.py62
1 files changed, 48 insertions, 14 deletions
diff --git a/redis/commands/core.py b/redis/commands/core.py
index 8dba5a2..90997ff 100644
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -2536,9 +2536,14 @@ class CoreCommands:
``score_cast_func`` a callable used to cast the score return value
"""
- return self.zrange(name, start, end, desc=True,
- withscores=withscores,
- score_cast_func=score_cast_func)
+ pieces = ['ZREVRANGE', name, start, end]
+ if withscores:
+ pieces.append(b'WITHSCORES')
+ options = {
+ 'withscores': withscores,
+ 'score_cast_func': score_cast_func
+ }
+ return self.execute_command(*pieces, **options)
def zrangestore(self, dest, name, start, end,
byscore=False, bylex=False, desc=False,
@@ -2575,7 +2580,13 @@ class CoreCommands:
If ``start`` and ``num`` are specified, then return a slice of the
range.
"""
- return self.zrange(name, min, max, bylex=True, offset=start, num=num)
+ if (start is not None and num is None) or \
+ (num is not None and start is None):
+ raise DataError("``start`` and ``num`` must both be specified")
+ pieces = ['ZRANGEBYLEX', name, min, max]
+ if start is not None and num is not None:
+ pieces.extend([b'LIMIT', start, num])
+ return self.execute_command(*pieces)
def zrevrangebylex(self, name, max, min, start=None, num=None):
"""
@@ -2585,8 +2596,13 @@ class CoreCommands:
If ``start`` and ``num`` are specified, then return a slice of the
range.
"""
- return self.zrange(name, max, min, desc=True,
- bylex=True, offset=start, num=num)
+ if (start is not None and num is None) or \
+ (num is not None and start is None):
+ raise DataError("``start`` and ``num`` must both be specified")
+ pieces = ['ZREVRANGEBYLEX', name, max, min]
+ if start is not None and num is not None:
+ pieces.extend(['LIMIT', start, num])
+ return self.execute_command(*pieces)
def zrangebyscore(self, name, min, max, start=None, num=None,
withscores=False, score_cast_func=float):
@@ -2602,10 +2618,19 @@ class CoreCommands:
`score_cast_func`` a callable used to cast the score return value
"""
- return self.zrange(name, min, max, byscore=True,
- offset=start, num=num,
- withscores=withscores,
- score_cast_func=score_cast_func)
+ if (start is not None and num is None) or \
+ (num is not None and start is None):
+ raise DataError("``start`` and ``num`` must both be specified")
+ pieces = ['ZRANGEBYSCORE', name, min, max]
+ if start is not None and num is not None:
+ pieces.extend(['LIMIT', start, num])
+ if withscores:
+ pieces.append('WITHSCORES')
+ options = {
+ 'withscores': withscores,
+ 'score_cast_func': score_cast_func
+ }
+ return self.execute_command(*pieces, **options)
def zrevrangebyscore(self, name, max, min, start=None, num=None,
withscores=False, score_cast_func=float):
@@ -2621,10 +2646,19 @@ class CoreCommands:
``score_cast_func`` a callable used to cast the score return value
"""
- return self.zrange(name, max, min, desc=True,
- byscore=True, offset=start,
- num=num, withscores=withscores,
- score_cast_func=score_cast_func)
+ if (start is not None and num is None) or \
+ (num is not None and start is None):
+ raise DataError("``start`` and ``num`` must both be specified")
+ pieces = ['ZREVRANGEBYSCORE', name, max, min]
+ if start is not None and num is not None:
+ pieces.extend(['LIMIT', start, num])
+ if withscores:
+ pieces.append('WITHSCORES')
+ options = {
+ 'withscores': withscores,
+ 'score_cast_func': score_cast_func
+ }
+ return self.execute_command(*pieces, **options)
def zrank(self, name, value):
"""