php教程_thinkphp redis用法是什么

 所属分类:php教程

 浏览:114次-  评论: 0次-  更新时间:2022-05-26
描述:这是一篇php教程_thinkphp redis用法是什么的说明内容,如果你想学习查找类似的文章,可以进入php教程获得最新优质资料。 thinkphp5如何使...
这是一篇php教程_thinkphp redis用法是什么的说明内容,如果你想学习查找类似的文章,可以进入php教程获得最新优质资料。

thinkphp5如何使用redis?

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

q.jpg

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

w.jpg

相关推荐:《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用法是什么的详细内容,更多请关注zzsucai网其它相关文章!

 标签:
积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!