如何彻底清除ThinkPHP5.0框架中的所有缓存?

2026-04-02 17:351阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计321个文字,预计阅读时间需要2分钟。

如何彻底清除ThinkPHP5.0框架中的所有缓存?

ThinkPHP5.0 清除缓存方法:

1.使用 `public function clear_sys_cache()` 函数清除版本缓存;

2.使用 `public function clear_log_cache()` 函数清除日志缓存并删除日志目录。

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

本教程操作环境:Windows7系统、thinkphp5.0版、Dell G3电脑。

thinkphp5.0 怎么清除缓存?

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

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

如何彻底清除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视频教程》

本文共计321个文字,预计阅读时间需要2分钟。

如何彻底清除ThinkPHP5.0框架中的所有缓存?

ThinkPHP5.0 清除缓存方法:

1.使用 `public function clear_sys_cache()` 函数清除版本缓存;

2.使用 `public function clear_log_cache()` 函数清除日志缓存并删除日志目录。

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

本教程操作环境:Windows7系统、thinkphp5.0版、Dell G3电脑。

thinkphp5.0 怎么清除缓存?

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

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

如何彻底清除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视频教程》