Name

clearCache() — 清除缓存

说明

void clearCache(string template,
string cache_id,
string compile_id,
int expire_time);

  • 模板中如果有使用多个缓存,则可以通过cache_id指定清除相关缓存。

  • 你可以指定第三个参数 $compile_id, 在模板组中清除一组模板,详见 缓存 了解更多。

  • 第四个参数提供了一个最小时间,在这时间到来之前,缓存将会被清除。


Example 14.11. clearCache()

  1. <?php
  2. // 清除特定模板的缓存
  3. $smarty->clearCache('index.tpl');
  4.  
  5. // 清除多个缓存的模板中某个特定缓存id的缓存
  6. $smarty->clearCache('index.tpl', 'MY_CACHE_ID');
  7. ?>
  8.  

参见 clearAllCache()缓存

原文: https://www.smarty.net/docs/zh_CN/api.clear.cache.tpl