thinkphp5使用redis


1.設置應用配置文件config.php

type可以是很多分類File、Redis等等



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 lang="en">
<head>
    <meta charset="UTF-8">
    <title>index/index</title>
</head>
<body>
    {$data}
</body>
</html>

輸出klc123

PS:使用redis,注意開啟redis服務器

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM