<?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
参考地址:fastadmin简单使用redis_fastapi_qq_39808028-华为开发者联盟HarmonyOS专区