diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2018-10-31 22:45:02 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2018-10-31 22:45:02 -0700 |
commit | eaf6b2d23ad3e9a46f141cc4fa0fa62240fadba9 (patch) | |
tree | 9dd7e92cd3e17faa150f297c8c604815d9df4e8c | |
parent | ad67d89d0fe34b59b798be68c787277f3ab781fc (diff) | |
download | redis-py-eaf6b2d23ad3e9a46f141cc4fa0fa62240fadba9.tar.gz |
rename start/finish and start/end args to min/max on all stream commands
this is consistent with the rest of the library and is clearer
terminology to the end user
-rwxr-xr-x | redis/client.py | 22 | ||||
-rw-r--r-- | tests/test_commands.py | 18 |
2 files changed, 20 insertions, 20 deletions
diff --git a/redis/client.py b/redis/client.py index f8d13b7..2ab938a 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1918,7 +1918,7 @@ class StrictRedis(object): """ return self.execute_command('XPENDING', name, groupname) - def xpending_range(self, name, groupname, start='-', end='+', count=-1, + def xpending_range(self, name, groupname, min='-', max='+', count=-1, consumername=None): """ Returns information about pending messages, in a range. @@ -1933,22 +1933,22 @@ class StrictRedis(object): consumername: name of a consumer to filter by (optional). """ pieces = [name, groupname] - if start is not None or end is not None or count is not None: - if start is None or end is None or count is None: - raise RedisError("XPENDING must be provided with start, end " + if min is not None or max is not None or count is not None: + if min is None or max is None or count is None: + raise RedisError("XPENDING must be provided with min, max " "and count parameters, or none of them. ") if not isinstance(count, (int, long)) or count < -1: raise RedisError("XPENDING count must be a integer >= -1") - pieces.extend((start, end, str(count))) + pieces.extend((min, max, str(count))) if consumername is not None: - if start is None or end is None or count is None: + if min is None or max is None or count is None: raise RedisError("if XPENDING is provided with consumername," - " it must be provided with start, end and" + " it must be provided with min, max and" " count parameters") pieces.append(consumername) return self.execute_command('XPENDING', *pieces, parse_detail=True) - def xrange(self, name, start='-', finish='+', count=None): + def xrange(self, name, min='-', max='+', count=None): """ Read stream values within an interval. name: name of the stream. @@ -1959,7 +1959,7 @@ class StrictRedis(object): count: if set, only return this many items, beginning with the earliest available. """ - pieces = [start, finish] + pieces = [min, max] if count is not None: if not isinstance(count, (int, long)) or count < 1: raise RedisError('XRANGE count must be a positive integer') @@ -2026,7 +2026,7 @@ class StrictRedis(object): pieces.extend(streams.values()) return self.execute_command('XREADGROUP', *pieces) - def xrevrange(self, name, start='+', finish='-', count=None): + def xrevrange(self, name, max='+', min='-', count=None): """ Read stream values within an interval, in reverse order. name: name of the stream @@ -2037,7 +2037,7 @@ class StrictRedis(object): count: if set, only return this many items, beginning with the latest available. """ - pieces = [start, finish] + pieces = [max, min] if count is not None: if not isinstance(count, (int, long)) or count < 1: raise RedisError('XREVRANGE count must be a positive integer') diff --git a/tests/test_commands.py b/tests/test_commands.py index 4e11b55..991d50a 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -37,7 +37,7 @@ def redis_server_time(client): def get_stream_message(client, stream, message_id): "Fetch a stream message and format it as a (message_id, fields) pair" - response = client.xrange(stream, start=message_id, finish=message_id) + response = client.xrange(stream, min=message_id, max=message_id) assert len(response) == 1 return response[0] @@ -1866,16 +1866,16 @@ class TestRedisCommands(object): def get_ids(results): return [result[0] for result in results] - results = r.xrange(stream, start=m1) + results = r.xrange(stream, min=m1) assert get_ids(results) == [m1, m2, m3, m4] - results = r.xrange(stream, start=m2, finish=m3) + results = r.xrange(stream, min=m2, max=m3) assert get_ids(results) == [m2, m3] - results = r.xrange(stream, finish=m3) + results = r.xrange(stream, max=m3) assert get_ids(results) == [m1, m2, m3] - results = r.xrange(stream, finish=m2, count=1) + results = r.xrange(stream, max=m2, count=1) assert get_ids(results) == [m1] @skip_if_server_version_lt('5.0.0') @@ -1994,16 +1994,16 @@ class TestRedisCommands(object): def get_ids(results): return [result[0] for result in results] - results = r.xrevrange(stream, start=m4) + results = r.xrevrange(stream, max=m4) assert get_ids(results) == [m4, m3, m2, m1] - results = r.xrevrange(stream, start=m3, finish=m2) + results = r.xrevrange(stream, max=m3, min=m2) assert get_ids(results) == [m3, m2] - results = r.xrevrange(stream, finish=m3) + results = r.xrevrange(stream, min=m3) assert get_ids(results) == [m4, m3] - results = r.xrevrange(stream, finish=m2, count=1) + results = r.xrevrange(stream, min=m2, count=1) assert get_ids(results) == [m4] @skip_if_server_version_lt('5.0.0') |