Cache Groups

You can do more elaborate grouping by setting up $cache_id groups. This is accomplished by separating each sub-group with a vertical bar | in the $cache_id value. You can have as many sub-groups as you like.

Cache grouping should not be confused with your template directory heirarchy, the cache grouping has no knowledge of how your templates are structured. So for example, if you have a template structure like themes/blue/index.tpl and you want to be able to clear all the cache files for the blue theme, you will need to create a cache group structure that mimics your template file structure, such as display('themes/blue/index.tpl','themes|blue'), then clear them with clear_cache(null,'themes|blue').

Example 14.9. $cache_id groups

$smarty = new Smarty;

$smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;

// clear all caches with 'sports|basketball' as the first two cache_id groups

// clear all caches with "sports" as the first cache_id group. This would
// include "sports|basketball", or "sports|(anything)|(anything)|(anything)|..."

// clear the foo.tpl cache file with "sports|basketball" as the cache_id