首先引用缓存文件

use think\Cache;

    public function index(){

        $data = Cache::get('showw');//去缓存
        if($data){
          echo '我是老缓存';
          $this->assign('data',$data);
        }else{
            db('cate')->cache('showw',5)->select();
            $data = Cache::get('showw');
            echo '我是刚缓存';
            $this->assign('data',$data);
         }


        //return $this->fetch();
    }

 

相关文章:

  • 2021-09-03
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-07-24
  • 2021-11-05
  • 2021-05-16
猜你喜欢
  • 2022-12-23
  • 2021-12-19
  • 2021-11-25
  • 2021-05-27
  • 2022-01-07
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案