
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用法是什么的细致内容,更多请关注ki4网别的相干文章!