diff options
Diffstat (limited to 'redis')
-rw-r--r-- | redis/__init__.py | 2 | ||||
-rw-r--r-- | redis/client.py | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/redis/__init__.py b/redis/__init__.py index 93155fb..18078af 100644 --- a/redis/__init__.py +++ b/redis/__init__.py @@ -3,6 +3,8 @@ from redis.client import Redis, ConnectionPool from redis.exceptions import RedisError, ConnectionError, AuthenticationError from redis.exceptions import ResponseError, InvalidResponse, InvalidData +__version__ = '1.36' + __all__ = [ 'Redis', 'ConnectionPool', 'RedisError', 'ConnectionError', 'ResponseError', 'AuthenticationError' diff --git a/redis/client.py b/redis/client.py index 0841c04..3dabcf4 100644 --- a/redis/client.py +++ b/redis/client.py @@ -208,7 +208,7 @@ class Redis(threading.local): ), string_keys_to_dict( 'DECRBY HLEN INCRBY LLEN SCARD SDIFFSTORE SINTERSTORE ' - 'SUNIONSTORE ZCARD ZREMRANGEBYSCORE ZREVRANK', + 'SUNIONSTORE ZCARD ZREMRANGEBYRANK ZREMRANGEBYSCORE ZREVRANK', int ), string_keys_to_dict( @@ -996,10 +996,19 @@ class Redis(threading.local): "Remove member ``value`` from sorted set ``name``" return self.execute_command('ZREM', name, value) + def zremrangebyrank(self, name, min, max): + """ + Remove all elements in the sorted set ``name`` with ranks between + ``min`` and ``max``. Values are 0-based, ordered from smallest score + to largest. Values can be negative indicating the highest scores. + Returns the number of elements removed + """ + return self.execute_command('ZREMRANGEBYRANK', name, min, max) + def zremrangebyscore(self, name, min, max): """ Remove all elements in the sorted set ``name`` with scores - between ``min`` and ``max`` + between ``min`` and ``max``. Returns the number of elements removed. """ return self.execute_command('ZREMRANGEBYSCORE', name, min, max) @@ -1283,3 +1292,4 @@ class Pipeline(Redis): def select(self, *args, **kwargs): raise RedisError("Cannot select a different database from a pipeline") + |