Skip to content

Commit ceda9cb

Browse files
committed
Merge branch 'lua-hmset' into test_merge
2 parents ea906f4 + 386a5de commit ceda9cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mockredis/script.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import threading
3+
from itertools import izip
34
from mockredis.exceptions import ResponseError
45

56
LuaLock = threading.Lock()
@@ -38,11 +39,16 @@ def _execute_lua(self, keys, args, client):
3839
def _call(*call_args):
3940
# redis-py and native redis commands are mostly compatible argument
4041
# wise, but some exceptions need to be handled here:
41-
if str(call_args[0]).lower() == 'lrem':
42+
nrm_cmd = str(call_args[0]).lower()
43+
if nrm_cmd == 'lrem':
4244
response = client.call(
4345
call_args[0], call_args[1],
4446
call_args[3], # "count", default is 0
4547
call_args[2])
48+
elif nrm_cmd == 'hmset':
49+
# redis-py hmset takes key value pairs in a dictionary and not as a flat list of arguments.
50+
call_iter = iter(call_args)
51+
response = client.call(next(call_iter), next(call_iter), dict(izip(call_iter, call_iter)))
4652
else:
4753
response = client.call(*call_args)
4854
return self._python_to_lua(response)

0 commit comments

Comments
 (0)