1

我使用 phpredis 扩展,当我调用时:

redis.call("ZREVRANGE", KEYS[1], start, endPos, 'WITHSCORES')

在 lua 脚本中,它返回

array(6) {
[0] =>
string(5) "10010"
[1] =>
string(2) "12"
[2] =>
string(5) "10012"
[3] =>
string(2) "-2"
[4] =>
string(5) "10011"
[5] =>
string(2) "-2"
}

实际上我想返回关联数组:

array(
"10010" => 12, "10012 => -2, ...
)
4

1 回答 1

0

我已经使用PREDIS实现了同样的事情,它完全按照你想要的方式返回。你可能想试试那个..

include 'Autoloader.php';

Autoloader::register();

$redis = new Predis\Client(array(
    "scheme" => "tcp",
    "host" => localhost,
    "port" => 6379,
));

$scores = $redis->zrevrange('key','start','end',withscores);
于 2013-09-24T08:18:26.040 回答