redis简单轮寻算法

196 阅读1分钟
function redislun($arrMaster, $key)
{
    $this->load->library('redis');
    sort($arrMaster);
    $intIndex = $this->yredis->incr($key);
    $intKey = $intIndex % count($arrMaster);
    return $arrMaster[$intKey];
}

$value = redislun([1,3,5,6,31,22,12,45,2], 'redis_key');