diff options
author | Itamar Haber <itamar@redislabs.com> | 2018-10-15 20:37:55 +0300 |
---|---|---|
committer | Roey Prat <roey.prat@redislabs.com> | 2018-10-28 12:12:53 +0200 |
commit | 1f8c69cfcd6c0fad819fc78777b56873ec8d26dc (patch) | |
tree | 3c32b515a6ea399b5b136940c7c28a55ec68aa50 | |
parent | f1ece6b139d7cf4a7900526ff1d53b1387d89c68 (diff) | |
download | redis-py-1f8c69cfcd6c0fad819fc78777b56873ec8d26dc.tar.gz |
Implements XACK
-rwxr-xr-x | redis/client.py | 12 | ||||
-rw-r--r-- | tests/test_commands.py | 10 |
2 files changed, 21 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index f3492da..410cdac 100755 --- a/redis/client.py +++ b/redis/client.py @@ -426,12 +426,13 @@ class StrictRedis(object): 'XGROUP DESTROY': int, 'XGROUP SETID': bool_ok, 'XGROUP DELCONSUMER': int - }, + }, { 'XINFO STREAM': parse_xinfo_dict, 'XINFO CONSUMERS': parse_xinfo_list, 'XINFO GROUPS': parse_xinfo_list }, + string_keys_to_dict('XACK', int), string_keys_to_dict( 'INCRBYFLOAT HINCRBYFLOAT GEODIST', float @@ -1952,6 +1953,15 @@ class StrictRedis(object): """ return self.execute_command('XINFO GROUPS', name) + def xack(self, name, groupname, *ids): + """ + Acknowledges the successful processing of one or more messages. + name: name of the stream. + groupname: name of the consumer group. + *ids: message ids to acknowlege. + """ + return self.execute_command('XACK', name, groupname, *ids) + # SORTED SET COMMANDS def zadd(self, name, *args, **kwargs): """ diff --git a/tests/test_commands.py b/tests/test_commands.py index 946934d..1f70230 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1732,6 +1732,16 @@ class TestStrictCommands(object): assert sr.xtrim(stream_name, 234) == 0 assert sr.xtrim(stream_name, 234, approximate=False) == 66 + @skip_if_server_version_lt('5.0.0') + def test_strict_xack(self, sr): + stream_name = 'xack_test_stream' + sr.delete(stream_name) + group_name = 'xack_test_group' + + assert sr.xack(stream_name, group_name, 0) == 0 + assert sr.xack(stream_name, group_name, '1-1') == 0 + assert sr.xack(stream_name, group_name, *[x for x in range(5)]) == 0 + def test_strict_zadd(self, sr): sr.zadd('a', 1.0, 'a1', 2.0, 'a2', a3=3.0) assert sr.zrange('a', 0, -1, withscores=True) == \ |