phpredis zRange回归

时间:2018-06-08 21:37:31

标签: php redis

尝试发布到此排行榜索引时,我收到了http 500错误:

<?php
$reference = "sorted";
$printboard = "leaderboard";

$my_win = 0;
$my_check = 0;


//get the name or member or element of the lowest score 
$my_check = $redis->zRange($reference, 0, 0);

//I have the lowest ranking member now get that members score to check against 
$my_win = $redis->zScore($reference, $my_check[0]);

//$wins is what I'm posting to this index
if ($my_win < $wins) {

$redis->zDelete($reference, $my_check);//I beat the lowest ranking user so take his spot 

//update the new score and push the new user to the print list 
$redis->zAdd($reference,$wins, $name);


//if im adding someone new I need to remove someone


//if this is running I want to strip the list of it's 99th user so don't use 1188 use 1176
$redis->listTrim($printboard, 0, 1176);

//then rpush the new player to have made the list 
$redis->rpush($printboard,$name,$avatar,$wins,$losses,$ties,$fave,$meter,$game1,$game2,$game3,$game4,$game5);

}

?>

我对zRange的使用是否正确?

$my_check = $redis->zRange($reference, 0, 0);

然后检查第一个阵列点?

$my_win = $redis->zScore($reference, $my_check[0]);

我认为这可能是我的问题,因为我错误地使用$ my_check的返回?

另外,使用Redis你需要初始化任何东西吗? 我经常浏览phpredis GitHub手册和redis网站本身并没有注意到如果你在一个空的排序集上使用zRange会发生什么的任何细节。

0 个答案:

没有答案