当前位置: 首页 > 新闻动态 > 技术教程

thinkphp redis用法是什么

作者:爱喝马黛茶的安东尼 浏览: 发布日期:2019-08-26
[导读]:设置应用配置文件config.php,将驱动方式设为“Redis”,将缓存保存在“CACHE_PATH”目录,设置缓存前缀,将缓存有效期设为0。然后新建application/index/controller/index.php即可。


thinkphp5如何使用redis?

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

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

相关推荐:《ThinkPHP教程》

2.thinkphp5使用redis

新建application/index/controller/index.php

set('name','klc123');
        $data = $han->get('name');
        $this->assign('data',$data);
        return view();
    }
}

3.前端显示

新建application/index/view/index.html




    
    index/index


    {$data}

输出:

klc123

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

免责声明:转载请注明出处:http://sczxchw.cn/news/58773.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!