thinkphp 删除所有缓存 Rumtime 以及 Html 静态缓存
来源:互联网 发布:人工智能ai在线观看 编辑:程序博客网 时间:2024/06/01 20:05
<?php/** * This is not a free software, All Copyright @F.Z.B * Date: 14-8-12 下午4:08 * File: CacheController.class.php * Author: default.fu@foxmail.com */namespace Api\Controller;class CacheController extends InitController{ public function cleanAll() { $this->totalSize = 0; $this->totalFile = 0; $GLOBALS['arrFiles'] = $GLOBALS['arrDirs'] = array(); $this->dropDir(HTML_PATH); $this->dropDir(RUNTIME_PATH); //ThinkPHP 3.2 不会自动生成Html缓存目录 if (!is_dir(HTML_PATH)) mkdir(HTML_PATH); $data = array( 'totalFile' => $this->totalFile, 'totalSize' => byte_format($this->totalSize), 'arrFiles' => $GLOBALS['arrFiles'], 'arrDirs' => $GLOBALS['arrDirs'], 'result' => 1, 'reqtime' => date('Y-m-d H:i:s'), ); $returnType = I('type') == 'JSON' ? 'JSON' : 'JSONP'; $this->ajaxReturn($data, $returnType); } public function dropDir($path = '') { $path = trimRepeatSlash($path); if (is_file($path)) { $this->totalSize += filesize($path); $this->totalFile++; $GLOBALS['arrFiles'][] = $path; unlink($path); } else if (is_dir($path)) { if (($dir = opendir($path)) !== false) { while (($file = readdir($dir)) !== false) { if ($file != '.' && $file != '..') { $this->dropDir($path . '/' . $file); } } $GLOBALS['arrDirs'][] = $path; rmdir($path); } } }}#thinkphp3.2.x设置缓存开启#<?phpreturn array( //'配置项'=>'配置值' 'LAYOUT_ON' => true, 'HTML_CACHE_ON' => strpos($_SERVER['HTTP_HOST'], '.') !== false, // 开启静态缓存 默认为 true 本地不开启 'HTML_CACHE_TIME' => 3600, // 全局静态缓存有效期(秒) 'HTML_FILE_SUFFIX' => '.shtml', // 设置静态缓存文件后缀 'HTML_CACHE_RULES' => array( '*' => array('{:module}/{:controller}/{:action}/{$_SERVER.REQUEST_URI|md5}', 3600, 'trimSW'), ));
#trimSW函数#/** * @author default.fu@foxmail.com * @description 去除 空格 和非\w 字符串,用于cache 配置 * * @param $str * @param string $emptyValue * * @return mixed|string */function trimSW($str, $emptyValue = '_empty_'){ $str = preg_replace('/([^\w\/]+)/', '-', $str); if (empty($str)) { $str = $emptyValue; } return $str;}
0 0
- thinkphp 删除所有缓存 Rumtime 以及 Html 静态缓存
- ThinkPHP 静态缓存类
- thinkphp 静态缓存 ReadHtmlCache
- thinkphp 静态缓存
- ThinkPHP清除缓存/删除文件夹下所有文件
- ThinkPHP清除缓存/删除文件夹下所有文件
- ThinkPHP生成HTML静态文件和模板缓存的过程
- thinkphp--静态缓存和动态缓存
- thinkphp的静态缓存使用方法
- thinkphp的静态缓存使用方法
- thinkphp删除Runtime缓存文件夹
- [php] ThinkPHP缓存技术(S(),F(),查询缓存,静态缓存)
- redis删除所有key缓存
- ThinkPHP静态缓存简单配置和使用
- ThinkPHP静态缓存简单配置和使用
- thinkphp 静态缓存页面的设置方法
- ThinkPHP的静态缓存,非系统写法。
- 自定义缓存策略,以及删除缓存
- DataCleanManager
- STL总结
- Linux内核动态调试信息的打开
- Linux下的实时流媒体(RTP)编程
- 从最简单的开始---配置jdk环境变量
- thinkphp 删除所有缓存 Rumtime 以及 Html 静态缓存
- 【Ubuntu】解压缩 unzip 命令详解
- Memcached客户端(memcached-Java-client)与 Spring集成(单服务器)
- Git版本管理工具的使用
- 制作统计图好用的软件
- 解析Java中静态变量与实例变量的区别
- java集合类中的迭代器模式
- abercrombie france large-scale comprehensive tests have been in full swing.According introduction
- 我若不来,怎与你相遇,你若不来,怎可与我结识?一场繁华,待落尽,谁是谁的梦?谁又是谁的客?一朵花,随缘而绽,缘来如夏花般灿烂,缘去如秋叶般静美,这是怎样的情愫?入夜,月凉如水,如水凉月,捻一缕青烟,让