Redis 有序集合和集合一样也是string类型元素的集合,且不允许重复的成员。
不同的是每个元素都会关联一个double类型的分数。redis正是通过分数来为集合中的成员进行从小到大的排序。
有序集合的成员是唯一的,但分数(score)却可以重复。若成员重复分数就会更新

1.新增有序集合

public function zaddSet($key,$arr = array()){
        if(is_array($arr)){
            foreach ($arr as $score => $value) {
                $this->redis->Zadd($key,$score,$value);
            }
        }
    }

2.获取有序集合 0 从第一个元素开始  -1 最后一个 -2倒数第二个 类推

public function zRange($key,$x,$y,$true = false){

        if($true == false){
            return $this->redis->zRange($key,$x,$y);
        }

        if($true == true){
            return $this->redis->zRange($key,$x,$y,true);
        }
        
    }

  

相关文章:

  • 2021-07-05
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-08-14
  • 2021-10-06
猜你喜欢
  • 2021-11-18
相关资源
相似解决方案