redis lua脚本调用redis.call(“ZREVRANGE”,KEYS [1],start,end,'WITHSCORES')

时间:2013-09-24 06:51:18

标签: php database redis phpredis

我使用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, ...
)

1 个答案:

答案 0 :(得分: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);