/** * 调度器直接读取静态页面缓存(会非常快) */ private function read_html_cache() { $url = getToUrl(); $filePath = APP_Cache_PATH . '/HtmlCache/' . md5($url); if (!file_exists($filePath)) { return false; } $html_cache_mtime = filemtime($filePath); $cache_expired_time = $html_cache_mtime + C('html_cache_time') * 60; if ($cache_expired_time > time()) { $content = file_get_contents($filePath); die($content); } else { return false; } }
/** * 生成静态页面缓存 * 读取配置html_cache_controller_array,只生成指定的控制器缓存 */ private function create_html_cache($content) { $cache_array = C('html_cache_controller_array'); if ($cache_array != false && C('html_cache_time') > 0) { $controller = $this->module_name . '/' . $this->action_name; if (in_array($controller, $cache_array)) { $url = getToUrl(); $filePath = APP_Cache_PATH . '/HtmlCache/' . md5($url); file_put_contents($filePath, $content); } } }