From 0f4c6281460c5816f6d1d557c6c98a39574419d9 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 3 Sep 2014 17:18:58 +0800 Subject: [PATCH] update py client --- client/ledis-py/ledis/client.py | 10 +++++++--- client/ledis-py/tests/test_cmd_script.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/ledis-py/ledis/client.py b/client/ledis-py/ledis/client.py index cffac29..034f2e3 100644 --- a/client/ledis-py/ledis/client.py +++ b/client/ledis-py/ledis/client.py @@ -906,11 +906,15 @@ class Ledis(object): return self.execute_command("BSCAN", key, match, count) def eval(self, script, keys, *args): - return self.execute_command('EVAL', script, len(keys), *keys, *args) + n = len(keys) + args = list_or_args(keys, args) + return self.execute_command('EVAL', script, n, *args) def evalsha(self, sha1, keys, *args): - return self.execute_command('EVALSHA', sha1, len(keys), *keys, *args) - + n = len(keys) + args = list_or_args(keys, args) + return self.execute_command('EVALSHA', sha1, n, *args) + def scriptload(self, script): return self.execute_command('SCRIPT', 'LOAD', script) diff --git a/client/ledis-py/tests/test_cmd_script.py b/client/ledis-py/tests/test_cmd_script.py index b2e2f18..02d7630 100644 --- a/client/ledis-py/tests/test_cmd_script.py +++ b/client/ledis-py/tests/test_cmd_script.py @@ -19,6 +19,7 @@ class TestCmdScript(unittest.TestCase): def tearDown(self): pass - + def testEval(self): + assert l.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", ["key1", "key2"], "first", "second") == ["key1", "key2", "first", "second"] \ No newline at end of file