1.设置应用配置文件config.php
type可以是很多分类file、redis等等。
相关推荐:《thinkphp教程》
2.thinkphp5使用redis
新建application/index/controller/index.php
<?phpnamespace app\index\controller;use think\controller;use think\cache;class index extends controller{ public function index() { $han = new cache; // halt($han); $han->set('name','klc123'); $data = $han->get('name'); $this->assign('data',$data); return view(); }}
3.前端显示
新建application/index/view/index.html
<!doctype html><html><head> <meta charset="utf-8"> <title>index/index</title></head><body> {$data}</body></html>
输出:
klc123
ps:使用redis,注意开启redis服务器。
以上就是thinkphp redis用法是什么的详细内容。
