summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorRoey Prat <roey.prat@redislabs.com>2018-10-29 11:32:34 +0200
committerRoey Prat <roey.prat@redislabs.com>2018-10-31 09:34:42 +0200
commit1dfda00588bc02ea37b76e4465111c91dd79635e (patch)
tree3f6f8f50824b86e4645ebc19795b8e5ab25023eb /redis/client.py
parentbb30ec5aae98c9649008303eacdcc64034bd506c (diff)
downloadredis-py-1dfda00588bc02ea37b76e4465111c91dd79635e.tar.gz
XCLAIM simplify argument checks
Diffstat (limited to 'redis/client.py')
-rwxr-xr-xredis/client.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/redis/client.py b/redis/client.py
index 2b39c2d..762b3a5 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -2013,25 +2013,28 @@ class StrictRedis(object):
pieces = [name, groupname, consumername, str(min_idle_time)]
pieces.extend(list(message_ids))
- optional_ints = {idle: 'idle', time: 'time', retrycount: 'retrycount'}
- optional_ints = {k: Token.get_token(v) for k, v in
- optional_ints.items()}
- for param_value, param_name in optional_ints.items():
- if param_value is not None:
- if not isinstance(param_value, (int, long)):
- raise RedisError("XCLAIM {0} must be an integer"
- .format(param_name))
- pieces.extend((param_name, str(param_value)))
-
- optional_bools = {force: 'force', justid: 'justid'}
- optional_bools = {k: Token.get_token(v) for k, v in
- optional_bools.items()}
- for param_value, param_name in optional_bools.items():
- if param_value:
- if not isinstance(param_value, bool):
- raise RedisError("XCLAIM {0} must be a boolean"
- .format(param_name))
- pieces.append(param_name.upper())
+ if idle is not None:
+ if not isinstance(idle, (int, long)):
+ raise RedisError("XCLAIM idle must be an integer")
+ pieces.extend((Token.get_token('IDLE'), str(idle)))
+ if time is not None:
+ if not isinstance(time, (int, long)):
+ raise RedisError("XCLAIM time must be an integer")
+ pieces.extend((Token.get_token('TIME'), str(time)))
+ if retrycount is not None:
+ if not isinstance(retrycount, (int, long)):
+ raise RedisError("XCLAIM retrycount must be an integer")
+ pieces.extend((Token.get_token('RETRYCOUNT'), str(retrycount)))
+
+ if force:
+ if not isinstance(force, bool):
+ raise RedisError("XCLAIM force must be a boolean")
+ pieces.append(Token.get_token('FORCE'))
+ if justid:
+ if not isinstance(justid, bool):
+ raise RedisError("XCLAIM justid must be a boolean")
+ pieces.append(Token.get_token('JUSTID'))
+
return self.execute_command('XCLAIM', *pieces)
# SORTED SET COMMANDS