ThinkPHP的静态缓存,非系统写法。

来源:互联网 发布:python黑帽子和灰帽子 编辑:程序博客网 时间:2024/06/05 02:29
public function viemore(){        $article_ids = I('get.article_id');        $arts_statis_file = HTML_PATH."art/art_".$article_ids.".html";        $content = $this->fetch('./viemore');        //检查缓存文件是否存在,并且采用模板文件        if(file_exists($arts_statis_file) && (time() - filemtime($arts_statis_file) < C('time'))){            $this->display(HTML_PATH."art/art_".$article_ids.".html");            exit;        }        ...处理数据,最后获取模板。        //获取模板        $content = $this->fetch('./viemore');        file_put_contents($arts_statis_file,$content);        $this->display('./viemore');    }
0 0
原创粉丝点击