Get Smarty

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:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

キャッシュのグループ

$cache_id のグループを設定する事で、 より複雑なグループにする事が出来ます。これは $cache_id の値の中の | によって各サブグループに分けられる事で実現できます。 サブグループはいくらでも持つ事が出来ます。

  • ディレクトリ階層のようなキャッシュグループを考える事が出来ます。 例えば 'a|b|c' というキャッシュグループは、 '/a/b/c/' というディレクトリ構造だと考えられます。

  • clear_cache(null,'a|b|c') はファイル '/a/b/c/*' を、 clear_cache(null,'a|b') はファイル '/a/b/*' を削除するのに似ています。

  • $compile_idclear_cache(null,'a|b','foo') のように指定すると、 それをキャッシュグループに追加して '/a/b/c/foo/' として扱います。

  • テンプレート名を clear_cache('foo.tpl','a|b|c') のように指定すると、 Smarty は '/a/b/c/foo.tpl' を削除しようと試みます。

  • また、'/a/b/*/foo.tpl' のように、 複数のキャッシュグループの下でテンプレート名を指定して削除する事は出来ません。 キャッシュグループは左から右へ向かう順序でのみグループ化を定義できます。 グループとしてそれらをクリアするためには、 単一のキャッシュグループ階層の下でテンプレートをグループ化する必要があります。

キャッシュのグループ化はテンプレートディレクトリ階層によって混乱させられるべきではなく、 テンプレートがどのような構造なのかも知り得ません。例えば、 themes/blue/index.tpl のようなテンプレート構造があり、 blue テーマのキャッシュファイルを全てクリアしたい時、 テンプレートファイル構造をまねた display('themes/blue/index.tpl','themes|blue') のような キャッシュグループ構造を作成する必要があり、それならば clear_cache(null,'themes|blue') によってキャッシュをクリアする事が出来ます。

Example 14.9. $cache_id groups


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

$smarty->caching = true;

// はじめの2つのcache_idグループが"sports|basketball"のキャッシュを全てクリアします。
$smarty->clear_cache(null,'sports|basketball');

// はじめのcache_idグループが"sports"のキャッシュを全てクリアします。
// これは"sports|basketball"又は"sports|(anything)|(anything)|(anything)|..."を用いてインクルードされたものでしょう。
$smarty->clear_cache(null,'sports');

// cache_id として"sports|basketball"を用いてfoo.tpl のキャッシュファイルをクリアします。
$smarty->clear_cache('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 19 plus 9? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk