12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types = 1);
- namespace app\common\model;
- use think\cache\driver\Redis;
- class RedisString
- {
- static private $instance;
- static private $handle;
- private function __construct(){
- self::$handle = (new Redis(config('cache.stores.redis')))->handler();
- }
- static public function getInstance(){
- if(!self::$instance instanceof self){
- self::$instance = new self();
- }
- return self::$instance;
- }
- //有序集合 添加
- public function zAdd($key,$score,$value){
- return self::$handle->zAdd($key,$score,$value);
- }
- //获取有序集合$value当前的排名排名从0开始
- public function zRevRank($key,$value){
- return self::$handle->zRevrank($key,$value);
- }
- //获取成员数 Zrangebyscore
- public function zRangeByScore($key,$min,$max){
- return self::$handle->zRangeByScore($key,(string)$min,(string)$max);
- }
- //移除指定区别的成员
- public function zREMRANGEBYSCORE($key,$min,$max){
- return self::$handle->zREMRANGEBYSCORE($key,(string)$min,(string)$max);
- }
- //查看有序集合指定区间内的成员
- public function zRange($key, $start=0, $stop=-1){
- return self::$handle->zRANGE($key,$start,$stop);
- }
- }
|