Home >php教程 >php手册 >部署在腾讯CEE+CMEM环境下的thinkPHP如何清理缓存

部署在腾讯CEE+CMEM环境下的thinkPHP如何清理缓存

WBOY
WBOYOriginal
2016-06-07 11:44:021726browse

使用环境为腾讯CEE+CMEM+CDB如何清理缓存。。。
部署在普通服务器的缓存可以通过删除换存目录来实现清理缓存的目的,但CEE是svn环境,缓存其实保存在CMEM,这个时候通过以前的办法就不能清理缓存了,现在讲讲如何清理掉cee+cmem应用中的缓存。<code><br> <?php <br />  <br> class cacheAction extends baseAction {<br>  <br>     protected $viewfiles = array();//模板文件<br>      <br>     public function clear_cache() {<br>         if (IS_CLOUD) {<br>             //取得所有模板文件<br>             $this->viewFielSearch();<br>             if(!empty($this->viewfiles)){<br>                 foreach ($this->viewfiles as $k => $f) {<br>                     //取得分组<br>                     $group = '';<br>                     $groups = explode(',', C('app_group_list'));<br>                     foreach ($groups as $g) {<br>                         if(false !== strpos($f, $g)){<br>                             $group = $g . '/';<br>                         }<br>                     }<br>                     //生成缓存文件名<br>                     $cachefile = CACHE_PATH . $group . md5($f).C('TMPL_CACHFILE_SUFFIX') . '.php';<br>                     if(F($cachefile) !== false){<br>                         F($cachefile,NULL);<br>                     }<br>                 }<br>             }<br>             $tables = M()->db()->getTables();<br>             foreach ($tables as $val) {<br>                 $db = C('DB_NAME');<br>                 $table = substr($val, strlen(C('DB_PREFIX')));<br>                 $key = '_fields/' . strtolower($db . '.' . $table);<br>                 F($key, NULL);<br>             }<br>         } else {<br>             $obj_dir = new Dir;<br>             is_dir(DATA_PATH . '_fields/') && $obj_dir->del(DATA_PATH . '_fields/');<br>             is_dir(CACHE_PATH) && $obj_dir->delDir(CACHE_PATH);<br>             is_dir(DATA_PATH) && $obj_dir->del(DATA_PATH);<br>             is_dir(TEMP_PATH) && $obj_dir->delDir(TEMP_PATH);<br>             is_dir(LOG_PATH) && $obj_dir->delDir(LOG_PATH);<br>             is_dir(MLSF_DATA_PATH . '/static/') && $obj_dir->del(MLSF_DATA_PATH . '/static/');<br>             @unlink(RUNTIME_FILE);<br>         }<br>         $this->ajaxReturn(1, L('clear_success'));<br>     }<br>  <br>     //遍历文件夹函数<br>     // $dir 初始文件夹<br>     // @author LiaoCaiXin<br>     private function viewFielSearch($dir="./app/Tpl"){<br>             if(is_dir($dir)&&file_exists($dir)){<br>                 $ob=scandir($dir);<br>                 foreach($ob as $file){<br>                     if($file=="."||$file==".."){<br>                         continue;<br>                     }<br>                     $file=$dir."/".$file;<br>                     if(is_file($file)){<br>                         $this->viewfiles[] = $file;<br>                     }elseif(is_dir($file)){<br>                         $this->viewFielSearch($file);<br>                     }<br>                 }<br>             }<br>         }<br> }<br> 原文地址:http://www.molibei.com/article/4.htm

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn