summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorRoey Prat <roey.prat@redislabs.com>2018-10-28 09:31:48 +0200
committerRoey Prat <roey.prat@redislabs.com>2018-10-28 14:13:42 +0200
commit9984fa9cbaea7d6380df090dfdc036042948dad1 (patch)
tree0ea6abebc37788559c33f59258b5bf43a13200c7 /redis/client.py
parent3d24b463dc44d74dec30cffc4c5a23c566975cea (diff)
downloadredis-py-9984fa9cbaea7d6380df090dfdc036042948dad1.tar.gz
XADD key/value pairs of the entry should be specified as a single dict arg rather than kwargs
Diffstat (limited to 'redis/client.py')
-rwxr-xr-xredis/client.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py
index a69b847..5ee99fa 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -1750,15 +1750,15 @@ class StrictRedis(object):
return self.execute_command('SUNIONSTORE', dest, *args)
# STREAMS COMMANDS
- def xadd(self, _name, id='*', maxlen=None, approximate=True, **kwargs):
+ def xadd(self, _name, fields, id='*', maxlen=None, approximate=True):
"""
Add to a stream.
_name: name of the stream (not using 'name' as this would
prevent 'name' used in the kwargs
+ 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
approximate: actual stream length may be slightly more than maxlen
- **kwargs: key/value pairs to insert into the stream
"""
pieces = []
@@ -1770,7 +1770,9 @@ class StrictRedis(object):
pieces.append('~')
pieces.append(str(maxlen))
pieces.append(id)
- for pair in iteritems(kwargs):
+ if not isinstance(fields, dict) or len(fields) == 0:
+ raise RedisError('XADD fields must be a non-empty dict')
+ for pair in iteritems(fields):
pieces.append(pair[0])
pieces.append(pair[1])
return self.execute_command('XADD', _name, *pieces)