什么是 Smarty?
为什么使用?
用例和工作流程
语法对比
模板继承
最佳实践
速成教程
clearCache() — 清除特定模板的缓存
void clearCache(string template,
                string cache_id,
                string compile_id,
                int expire_time);如果模板有多个缓存,可通过提供第二个参数cache_id来清除特定缓存。
还可将$compile_id作为第三个参数传入。可将模板组合在一起,然后作为一个整体移除,有关更多信息,请参阅缓存章节。
作为可选的第四个参数,可提供缓存文件的最小更新时间(以秒为单位),早于此时间的文件都将被清除。
从 Smarty 3.1.14 版本开始,可通过传递常量 SMARTY::CLEAR_EXPIRED 作为第四个参数来删除按创建时的过期时间划分的缓存文件。
示例 14.11. clearCache()
<?php
// clear the cache for a template
$smarty->clearCache('index.tpl');
// clear the cache for a particular cache id in an multiple-cache template
$smarty->clearCache('index.tpl', 'MY_CACHE_ID');
?>
   还可参见clearAllCache()和caching章节。