update py client

This commit is contained in:
siddontang 2014-09-03 17:18:58 +08:00
parent 855682ff2b
commit 0f4c628146
2 changed files with 9 additions and 4 deletions

View File

@ -906,11 +906,15 @@ class Ledis(object):
return self.execute_command("BSCAN", key, match, count) return self.execute_command("BSCAN", key, match, count)
def eval(self, script, keys, *args): 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): 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): def scriptload(self, script):
return self.execute_command('SCRIPT', 'LOAD', script) return self.execute_command('SCRIPT', 'LOAD', script)

View File

@ -19,6 +19,7 @@ class TestCmdScript(unittest.TestCase):
def tearDown(self): def tearDown(self):
pass pass
def testEval(self):
assert l.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", ["key1", "key2"], "first", "second") == ["key1", "key2", "first", "second"]