首页 > PHP
ThinkPHP6中Redis队列基础操作
来源:TP课堂 时间:2021-01-12 点击:425
<?php
namespace app\index\controller;
use app\BaseController;
use Redis;

class RedisText extends BaseController

{

    //加入队列
    function add()
    {
        //用户确认收货,有用户买东西id=2,买完后一直没有确认收货,系统15天后就自动确认收货
        //24小时没有支付订单,自动取消订单

        $orderId='8';
        
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $result=$redis->zAdd('order','8',$orderId);//score有排序的功能
        halt($result);
    }

    //查询队列
    public function lists(){
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $data = $redis->zRange('order',0,-1);
        halt($data);
    }

    //移除队列
    public function del(){
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $res=$redis->zRem('order','12');
        halt($res);
    }









}