thinkphp如何使用redis
互联网
19-8-22

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的详细内容,更多内容请关注技术你好其它相关文章!
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场