Smarty緩存集合
Cache Groups [緩存集合]
你可以通過建立cache_id集合做更祥細的集合體。在cache_id的值裏用豎線"|"來分開子集合。你可以儘可能多的包含子集合。
Example 14-9. cache_id groups
例14-9.cache_id集合
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;
// clear all caches with "sports|basketball" as the first two cache_id groups
$smarty->clear_cache(null,"sports|basketball");
// www.yiibai.com/smarty
// clear all caches with "sports" as the first cache_id group. This would
// include "sports|basketball", or "sports|(anything)|(anything)|(anything)|..."
$smarty->clear_cache(null,"sports");
$smarty->display('index.tpl',"sports|basketball");
技術提示:緩存集合並不像cache_id一樣對模板使用路徑。比如,如果你display('themes/blue/index.tpl'),那麼在"themes/blue"目錄下你並不能清除緩存。想要清除緩存,必須先用cache_id把緩存集合,像這樣display('themes/blue/index.tpl','themes|blue');然後就可以用clear_cache(null,'themes|blue')清除blue theme(藍色主題?!老外也真會叫...)下的緩存。