diff options
Diffstat (limited to 'redis/commands.py')
-rw-r--r-- | redis/commands.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/redis/commands.py b/redis/commands.py index 3d5670e..5aae14a 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -1640,17 +1640,25 @@ class Commands: return self.execute_command('XACK', name, groupname, *ids) def xadd(self, name, fields, id='*', maxlen=None, approximate=True, - nomkstream=False): + nomkstream=False, minid=None, limit=None): """ Add to a stream. name: name of the stream fields: dict of field/value pairs to insert into the stream id: Location to insert this record. By default it is appended. - maxlen: truncate old stream members beyond this size + maxlen: truncate old stream members beyond this size. + Can't be specify with minid. + minid: the minimum id in the stream to query. + Can't be specify with maxlen. approximate: actual stream length may be slightly more than maxlen nomkstream: When set to true, do not make a stream + limit: specifies the maximum number of entries to retrieve """ pieces = [] + if maxlen is not None and minid is not None: + raise DataError("Only one of ```maxlen``` or ```minid```", + "may be specified") + if maxlen is not None: if not isinstance(maxlen, int) or maxlen < 1: raise DataError('XADD maxlen must be a positive integer') @@ -1658,6 +1666,14 @@ class Commands: if approximate: pieces.append(b'~') pieces.append(str(maxlen)) + if minid is not None: + pieces.append(b'MINID') + if approximate: + pieces.append(b'~') + pieces.append(minid) + if limit is not None: + pieces.append(b"LIMIT") + pieces.append(limit) if nomkstream: pieces.append(b'NOMKSTREAM') pieces.append(id) @@ -2002,7 +2018,7 @@ class Commands: name: name of the stream. maxlen: truncate old stream messages beyond this size approximate: actual stream length may be slightly more than maxlen - minin: the minimum id in the stream to query + minid: the minimum id in the stream to query limit: specifies the maximum number of entries to retrieve """ pieces = [] |