web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

thinkphp如何清除缓存(禁止缓存)

1237 ℃
     

thinkphp如何清除缓存,如何禁止缓存?下面web建站小编给大家详细介绍一下!

thinkphp5.0清除缓存、模版缓存和日志缓存的方法

namespace app\cache\controller;
use think\Controller;
use think\Cache;

具体方法如下:

public function Index()
{
return $this->fetch();
}
//清除模版缓存不删除cache目录;
public function clear_sys_cache()
{
Cache::clear();
$this->success('清除成功', 'Index/index');
}
//清除模版缓存但不删除temp目录;
public function clear_temp_ahce()
{
$path = glob(TEMP_PATH . '*.php');
array_map('unlink', $path);
$this->success('清除成功', 'Index/index');
}
//清除日志缓存并删出log空目录;
public function clear_log_chache()
{
$path = glob(LOG_PATH . '*');
foreach ($path as $item) {
//dump(glob($item .DS. '*.log'));
array_map('unlink', glob($item . DS . '*.log'));
rmdir($item);
}
$this->success('清除成功', 'Index/index');
}

thinkphp如何禁止缓存?

1. 找到\ThinkPHP\Common\convention.php和\ThinkPHP\Common\debug.php

2.修改如下

debug.php中

'TMPL_CACHE_ON'=>false,      // 默认开启模板缓存

convention.php中

'TMPL_CACHE_ON'   => false,  // 默认开启模板编译缓存 false 的话每次都重新编译模板
'ACTION_CACHE_ON'  => false,  // 默认关闭Action 缓存
'HTML_CACHE_ON'   => false,   // 默认关闭静态缓存

3.关闭模版缓存, config.php中配置

'TMPL_CACHE_ON' => false,
'TMPL_CACHE_ON' => false,

ThinkPHP如何做页面404异常

ThinkPHP如何实现获取SQL的方法

wordpress如何清除用户缓存(步骤流程介绍)

thinkphp如何实现添加数据(批量添加数据)

thinkphp如何实现排序代码介绍

标签: thinkphp, 清除缓存, 禁止缓存

上面是“thinkphp如何清除缓存(禁止缓存)”的全面内容,想了解更多关于 后端开发 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_2877.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > 后端开发
本文共计990个字,预计阅读时长7分钟
生活小工具,收录了80多款小工具
上一篇: WordPress用自定义代码实现更高级的分页功能
下一篇: 车牌号输入HTML模板下载
x 打工人ai神器