3

该脚本适用于我的 MAC,phpinfo()显示 php redis 支持版本为:Redis 版本 2.2.5

我在 PHP 中的脚本是:

$script
    = "
        local count = redis.call('incr',KEYS[1])
        if tonumber(count) == 1 then
            redis.call('expire',KEYS[1],ARGV[1])
        end
        return count";

//$sha1_value = $this->conn->script('load', $script);
//var_dump($sha1_value);
if (FALSE === $this->conn->evalSha('e03b35e8ef29c5c746b1791ec7ae89e19f52156c', [
        $key,
        1800
    ], 1)
)
{
    $this->conn->eval($script, [
        $key,
        1800
    ], 1);
}

该脚本在我的服务器上不起作用,PHP 的 Redis 版本是 2.1.0。

问题是程序遇到$this->conn->script()or$this->conn->evalSha()方法会终止进程,这很奇怪,因为没有打印出错误日志,而且当我使用这种try ... catch ...方式编写代码时,也没有打印出异常消息。

我查看了 Redis 的官方网站,上面写着:

EVAL and EVALSHA are used to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.( http://redis.io/commands/EVAL )

所以我很好奇,因为我服务器上的redis-cli版本已经是2.8.0,而我的MAC上是3.0.2。

那么我怎样才能找出问题所在呢?

4

0 回答 0