thinkphp如何使用redis

thinkphp如何使用redis

thinkphp5如何使用redis

1.设置应用配置文件config.php

thinkphp如何使用redis

type可以是很多分类File、redis等等。

立即学习PHP免费学习笔记(深入)”;

thinkphp如何使用redis

相关推荐:《ThinkPHP教程

2.thinkphp5使用redis

新建application/index/controller/index.php

<?php namespace appindexcontroller; use thinkController; use thinkCache; class Index extends Controller {     public function index()     {             $han = new Cache;         // halt($han);         $han->set('name','klc123');         $data = $han-&gt;get('name');         $this-&gt;assign('data',$data);         return view();     } }

3.前端显示

新建application/index/view/index.html

nbsp;html&gt;       <meta>     <title>index/index</title>     {$data}  

输出:

klc123

PS:使用redis,注意开启redis服务器。

以上就是

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享