diff options
author | Itamar Haber <itamar@redislabs.com> | 2018-10-15 21:24:31 +0300 |
---|---|---|
committer | Roey Prat <roey.prat@redislabs.com> | 2018-10-28 12:12:54 +0200 |
commit | f5f9bef17dabcacd3efdd9229af6fe9701628788 (patch) | |
tree | 0413f2137293d6ae64baf8fd9b892f75f14729bc /redis/client.py | |
parent | 2a15e07f1a8aec26d287ec31ed330f598a1fca00 (diff) | |
download | redis-py-f5f9bef17dabcacd3efdd9229af6fe9701628788.tar.gz |
Implements XTRIM
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index 45b9879..136f36d 100755 --- a/redis/client.py +++ b/redis/client.py @@ -433,7 +433,7 @@ class StrictRedis(object): 'XINFO GROUPS': parse_xinfo_list }, string_keys_to_dict( - 'XACK XDEL', + 'XACK XDEL XTRIM', int ), string_keys_to_dict( @@ -1973,6 +1973,19 @@ class StrictRedis(object): """ return self.execute_command('XDEL', name, *ids) + def xtrim(self, name, maxlen, approximate=True): + """ + Trims old messages from a stream. + name: name of the stream. + maxlen: truncate old stream messages beyond this size + approximate: actual stream length may be slightly more than maxlen + """ + pieces = ['MAXLEN'] + if approximate: + pieces.append('~') + pieces.append(maxlen) + return self.execute_command('XTRIM', name, *pieces) + # SORTED SET COMMANDS def zadd(self, name, *args, **kwargs): """ |