如何从外部脚本清除Typo3中的缓存?
问题描述:
我确实有一个PHP脚本,它不是Typo3的扩展。现在,我想从该脚本中删除整个Typo3缓存。怎么可能?
I do have a PHP script, which is not an extension for Typo3. Now I would like to delete the whole Cache of Typo3 out of this script. How is that possible?
答
我自己找到了解决方案,实际上很简单。我查看了 t3lib 文件夹中的 class.t3lib_tcemain.php 。那里有清除缓存的必要命令。它还会检查您是否启用了cachingframework。如果是这样,您还需要截断一些其他表(以 cachingframework_cache _ 开头)
I found the solution myself and its actually pretty easy. I took a look into the class.t3lib_tcemain.php in the t3lib folder. There you've got the necessary commands to clear the cache. It also checks, if you have the cachingframework enabled. If so, you need to truncate a few other tables as well (Starts with cachingframework_cache_)
基本上是:
<?php
require_once('./typo3conf/localconf.php');
$conn = mysql_connect($typo_db_host, $typo_db_username, $typo_db_password);
mysql_select_db($typo_db);
// Clear Cache here
mysql_query("TRUNCATE cache_treelist;");
mysql_query("TRUNCATE cache_pagesection;");
mysql_query("TRUNCATE cache_hash;");
mysql_query("TRUNCATE cache_pages;");
if($handle = opendir('./typo3conf')) {
while (false !== ($file = readdir($handle))) {
if(strpos($file, 'temp_CACHED_')!==false) {
unlink('./typo3conf/'.$file);
}
}
closedir($handle);
}
?>