redis-py是否会自动将evalsha用于已注册的脚本?

use*_*217 2 redis redis-py

当我将Lua脚本注册到redis客户端时:

script = redis_client.register_script(lua_string)
Run Code Online (Sandbox Code Playgroud)

然后使用默认客户端运行脚本:

script(keys, args)
Run Code Online (Sandbox Code Playgroud)

这会自动在内部使用evalsha还是每次都将整个脚本发送到服务器?

Kev*_*nry 5

是.这是(删节)源代码:

class Script(object):
    def __call__(self, keys=[], args=[], client=None):
        if isinstance(client, BasePipeline):
            # Make sure the pipeline can register the script before executing.
            client.scripts.add(self)

        return client.evalsha(self.sha, len(keys), *args)
Run Code Online (Sandbox Code Playgroud)