验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

thinkphp5.0如何清除缓存

阅读:503 来源:乙速云 作者:代码code

thinkphp5.0如何清除缓存

thinkphp5.0清除缓存的方法:1、通过“public function clear_sys_cache(){...}”方法清除模版缓存;2、通过“public function clear_log_chache(){...}”方法清除日志缓存并删出log空目录即可。

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

直接写入cache模块中,生成控制器

namespace appcachecontroller;
use thinkController;
use thinkCache;

具体方法如下:

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');
}