Home  >  Article  >  php教程  >  如何清除TP的文件缓存

如何清除TP的文件缓存

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

很多时候,当我们在操作过程中,调整了表结构或者需要因为特殊的原因手动清理掉某些缓存文件时,需要用到这个方法。仅限于File缓存的方式。
很多时候,当我们在操作过程中,调整了表结构或者需要因为特殊的原因手动清理掉某些缓存文件时,需要用到这个方法。仅限于File缓存的方式。

如果要删除其他的缓存也是可以的,你可以去找一下TP的系统变量,里面有其他几个缓存目录的常量。

使用方法,直接用调用cache_clear方法即可。写的比较简单,如果需要请自行扩充,另外,很多教程里说,要用到IO类来删除缓存,可惜的是TP的3.1版本之后都没看到这个类在那里。或许是我没找到。public function cache_clear() {<br>         $this->deldir(TEMP_PATH);<br>     }<br> <br>     function deldir($dir) {<br>         $dh = opendir($dir);<br>         while ($file = readdir($dh)) {<br>             if ($file != "." && $file != "..") {<br>                 $fullpath = $dir . "/" . $file;<br>                 if (!is_dir($fullpath)) {<br>                     unlink($fullpath);<br>                 } else {<br>                     deldir($fullpath);<br>                 }<br>             }<br>         }<br>     }

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