您当前的位置: 首页 >  缓存

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

漏刻有时 发布时间:2019-05-29 13:24:24 ,浏览量:0

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

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

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0424s