Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

缓存组

你可以通过设置$cache_id更精细地组织你的缓存。 在$cache_id值中使用竖线|来设置缓存组, 同时你可以根据需要设置多个缓存组。

  • 你可以把缓存组理解成目录层次结构。 比如缓存组'a|b|c'可以理解成目录结构'/a/b/c/'

  • clearCache(null,'a|b|c')相等于删除文件 '/a/b/c/*'clearCache(null,'a|b')相等于删除文件 '/a/b/*'

  • 如果你按照clearCache(null,'a|b','foo')的方式来设置 $compile_id, 那么它将自动附带一个$compile_id 的缓存组。

  • 如果你按照clearCache('foo.tpl','a|b|c')的方式来设置模板名称, 然后Smarty将试图删除'/a/b/c/foo.tpl'

  • 因为缓存组是“从左到右”顺序删除缓存的,所以你不能单独删除某个缓存如'/a/b/*/foo.tpl'。 你可以另外再设置一个缓存组来达到此目的。

不能混淆缓存组和模板目录结构,缓存组与你的模板层次结构是无关的。 比如说,你有一个模板文件themes/blue/index.tpl, 然后你想删除全部带blue的主题(theme), 这样你可以参考模板目录结构来创建一个缓存组,如 display('themes/blue/index.tpl','themes|blue'), 之后你可以通过clearCache(null,'themes|blue')来删除它们。

Example 15.9. $cache_id 组


<?php
require('Smarty.class.php');
$smarty = new Smarty;

$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);

// 删除全部'sports|basketball'的缓存
$smarty->clearCache(null,'sports|basketball');

// 删除全部"sports"下的缓存,这里包括了
// "sports|basketball", 或者 "sports|(anything)|(anything)|(anything)|..."等等
$smarty->clearCache(null,'sports');

// 删除"sports|basketball"下的foo.tpl缓存文件
$smarty->clearCache('foo.tpl','sports|basketball');


$smarty->display('index.tpl','sports|basketball');
?>

      

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 14 plus 19? (Are you human?)

Advertisement