zoukankan      html  css  js  c++  java
  • thinkphp5.0 cache数据缓存机制

    use thinkcache;

    public function index(){

      //Cache::get('name')获取缓存,如果name值不存在则返回false;

      if (Cache::get('name')){

        echo "<script>alert('旧缓存');</script>"

      }else{

        $new = new indexModel;

        $name = $new->$lst();

        Cache::set('name',$name,60); //60为缓存的有效时间60秒。不设置或设置为0则为永久缓存, $name为缓存的数据,name则为在缓存里的变量名

        echo "<script>alert('新缓存');</script>"

      }

      $this->assign([

        'name'=>cache('name')

      ]);

    }

  • 相关阅读:
    第三次jsp作业
    快速排列 使用链表
    Cross
    题目
    ranch
    robot
    Mold
    Mold2
    OX_pattern
    KSC sort
  • 原文地址:https://www.cnblogs.com/junyi-bk/p/10319935.html
Copyright © 2011-2022 走看看