![](https://img.php.cn/upload/article/000/000/037/5d639132e9298196.jpg)
thinkphp5如何使用redis?
1.设置应用配置文件config.php
type可以是很多分类File、Redis等等。
相关推荐:《ThinkPHP教程》
2.thinkphp5使用redis
新建application/index/controller/index.php
<?php namespace 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用法是什么的详细内容,更多请关注php中文网其它相关文章!
![php中文网最新课程二维码](/static/images/article_wechat2021.jpg?1111)
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
- 上一篇:thinkphp框架的优势有哪些
- 下一篇:thinkphp5的优点是什么
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论