<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\cache\driver\Redis;
use think\Request;

class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    protected $redis;


    public function __construct(Request $request = null)
    {
        $this->redis = new Redis();
    }
    
    // 存
    public function index()
    {
        $this->redis->set('data',['id'=>1,'name'=>'嘿嘿嘿']);
    }

    // 取
    public function getredisdata(){
        $data = $this->redis->get('data');
    }
}

redis配置文件目录
\thinkphp\library\think\cache\driver\Redis.php

Logo

鸿蒙生态一站式服务平台。

更多推荐