evalSha 命令/方法/函数


Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. In order to run this command Redis will have to have already loaded the script, either by running it or via the SCRIPT LOAD command.


script_sha string. The sha1 encoded hash of the script you want to run.

args array, optional. Arguments to pass to the LUA script.

num_keys int, optional. The number of arguments that should go into the KEYS array, vs. the ARGV array when Redis spins the script

Return value

Mixed. See EVAL


$script = 'return 1';

$sha = $redis->script('load', $script);

$redis->evalSha($sha); // Returns 1