| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 24249 -->
- <sect1 id="zend.cache.frontends">
- <title><classname>Zend_Cache</classname> のフロントエンド</title>
- <sect2 id="zend.cache.frontends.core">
- <title>Zend_Cache_Core</title>
- <sect3 id="zend.cache.frontends.core.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Core</classname> は特別なフロントエンドであり、
- モジュールのコアに含まれています。これはキャッシュフロントエンドの
- 基本機能を実装したものであり、他のクラスによってオーバーライドされます。
- </para>
- <note><para>
- その他のフロントエンドクラスは、すべて <classname>Zend_Cache_Core</classname>
- を継承しており、以下で説明しているメソッドおよびオプションは
- 他のフロントエンドでも使用可能です。そのため、ここではこれらについての
- 詳しい説明は省略します。
- </para></note>
- </sect3>
- <sect3 id="zend.cache.frontends.core.options">
- <title>使用可能なオプション</title>
- <para>
- これらのオプションを、先の例で示したようにファクトリメソッドに渡します。
- </para>
- <table id="zend.cache.frontends.core.options.table">
- <title>Core フロントエンドのオプション</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>オプション</entry>
- <entry>データ型</entry>
- <entry>デフォルト値</entry>
- <entry>説明</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><emphasis>caching</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>TRUE</constant></entry>
- <entry>
- キャッシングを有効/無効にします
- (キャッシュされたスクリプトのデバッグ時に有用です)。
- </entry>
- </row>
- <row>
- <entry><emphasis>cache_id_prefix</emphasis></entry>
- <entry><type>String</type></entry>
- <entry><constant>NULL</constant></entry>
- <entry>
- すべてのキャッシュ ID のプレフィックス。<constant>NULL</constant> を指定すると、
- プレフィックスは使用しません。
- キャッシュ ID のプレフィックスは、いわばキャッシュ内での名前空間です。
- これによって、複数のアプリケーションやウェブサイトで
- キャッシュを共用できるようになります。
- 個々のアプリケーションやウェブサイトで
- それぞれ異なるキャッシュ ID プレフィックスを用いるようにすれば、
- 特定のキャッシュ ID をそれぞれの環境で使用できるようになります。
- </entry>
- </row>
- <row>
- <entry><emphasis>lifetime</emphasis></entry>
- <entry><type>Integer</type></entry>
- <entry>3600</entry>
- <entry>
- キャッシュの有効期間 (秒)。<constant>NULL</constant>
- を指定すると、有効期間が無期限となります。
- </entry>
- </row>
- <row>
- <entry><emphasis>logging</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- <constant>TRUE</constant> を指定すると、<classname>Zend_Log</classname> によるロギングが有効になります
- (しかし、処理速度は低下します)。
- </entry>
- </row>
- <row>
- <entry><emphasis>write_control</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>TRUE</constant></entry>
- <entry>
- 書き込み制御を有効/無効にします (壊れたエントリを検出するため、
- 書き込んだ直後にそのキャッシュを読み込みます)。
- writeControl を有効にすると、キャッシュの書き込みがやや遅くなりますが、
- 読み込みの速度は変わりません
- (これはキャッシュファイルが壊れているかどうかを調べるものですが、
- 完全に判断できるわけではありません)。
- </entry>
- </row>
- <row>
- <entry><emphasis>automatic_serialization</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- 自動シリアライズを有効/無効にします。
- 文字列でないデータを直接保存する際に使用します
- (しかし、処理速度は低下します)。
- </entry>
- </row>
- <row>
- <entry><emphasis>automatic_cleaning_factor</emphasis></entry>
- <entry><type>Integer</type></entry>
- <entry>10</entry>
- <entry>
- 自動クリーンアッププロセス (ガベージコレクタ) の設定を行います。
- 0 を指定すると、自動キャッシュクリーニングを行いません。
- 1 を指定すると計画的にキャッシュのクリーニングを行い、また
- x (1 より大きな整数) を指定すると、
- x 回のキャッシュ書き込みについて 1 回の頻度で
- ランダムに自動クリーニングを行います。
- </entry>
- </row>
- <row>
- <entry><emphasis>ignore_user_abort</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- <constant>TRUE</constant> を指定すると、<methodname>save()</methodname> メソッド内で
- <acronym>PHP</acronym> の ignore_user_abort フラグを設定し、
- キャッシュが破壊されることを防ぎます。
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- <sect3 id="zend.cache.core.examples">
- <title>例</title>
- <para>
- マニュアルのいちばんはじめのほうに、例を示しています。
- </para>
- <para>
- もしキャッシュに文字列しか保存しないのなら
- ("automatic_serialization" オプションを使用すると boolean も保存できるので)、
- このようにもう少しコンパクトに作成することが可能です。
- </para>
- <programlisting language="php"><![CDATA[
- // すでに $cache が存在するものとします
- $id = 'myBigLoop'; //「キャッシュしたい内容」のキャッシュ ID
- if ( ($data = $cache->load($id)) === false ) {
- // キャッシュが存在しませんでした
- $data = '';
- for ($i = 0; $i < 10000; $i++) {
- $data = $data . $i;
- }
- $cache->save($data);
- }
- // [...] $data を用いて何かをします (echo したり、何かに渡したりなど)
- ]]></programlisting>
- <para>
- 複数のブロックやデータのインスタンスをキャッシュしたい場合も、考え方は同じです。
- </para>
- <programlisting language="php"><![CDATA[
- // 一意な ID を使用するようにしましょう
- $id1 = 'foo';
- $id2 = 'bar';
- // ブロック 1
- if ( ($data = $cache->load($id1)) === false ) {
- // キャッシュが存在しませんでした
- $data = '';
- for ($i=0;$i<10000;$i++) {
- $data = $data . $i;
- }
- $cache->save($data);
- }
- echo($data);
- // これは、キャッシュ処理の影響を受けません
- echo('キャッシュされません !');
- // ブロック 2
- if ( ($data = $cache->load($id2)) === false ) {
- // キャッシュが存在しませんでした
- $data = '';
- for ($i=0;$i<10000;$i++) {
- $data = $data . '!';
- }
- $cache->save($data);
- }
- echo($data);
- ]]></programlisting>
- <para>
- 特殊な値 (boolean 値に "automatic_serialization" オプションを指定したものなど)
- や空の文字列をキャッシュしたい場合は、
- 上で示したコンパクトな例を使用することはできません。
- キャッシュレコードを正式に調べる必要があります。
- </para>
- <programlisting language="php"><![CDATA[
- // コンパクトな構文
- // (空の文字列や boolean をキャッシュする場合はうまくいきません)
- if ( ($data = $cache->load($id)) === false ) {
- // キャッシュが存在しませんでした
- // [...] $data を作成します
- $cache->save($data);
- }
- // $data に対して何らかの操作をします
- // [...]
- // 完全な構文 (どんな場合でも動作します)
- if (!($cache->test($id))) {
- // キャッシュが存在しませんでした
- // [...] $data を作成します
- $cache->save($data);
- } else {
- // キャッシュが見つかりました
- $data = $cache->load($id);
- }
- // $data に対して何らかの操作をします
- ]]></programlisting>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.output">
- <title>Zend_Cache_Frontend_Output</title>
- <sect3 id="zend.cache.frontends.output.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Frontend_Output</classname> は、出力を横取りするフロントエンドです。
- これは <acronym>PHP</acronym> の出力バッファリング処理を使いやすくしたもので、
- <methodname>start()</methodname> メソッドと
- <methodname>end()</methodname> メソッドの間の出力を横取りします。
- </para>
- </sect3>
- <sect3 id="zend.cache.frontends.output.options">
- <title>使用可能なオプション</title>
- <para>
- <classname>Zend_Cache_Core</classname> のオプション以外に、
- このフロントエンドが独自に使用するオプションはありません。
- </para>
- </sect3>
- <sect3 id="zend.cache.frontends.output.examples">
- <title>例</title>
- <para>
- このマニュアルの冒頭に示した例とほとんど同じですが、少しだけ変更を加えています。
- </para>
- <programlisting language="php"><![CDATA[
- // キャッシュが見つからなかった場合に、出力バッファリングが起動します
- if (!($cache->start('mypage'))) {
- // すべてをいつもどおりに出力しますoutput everything as usual
- echo 'Hello world! ';
- echo 'これはキャッシュされます ('.time().') ';
- $cache->end(); // 出力バッファリングを終了します
- }
- echo 'これはキャッシュされません ('.time().').';
- ]]></programlisting>
- <para>
- この形式を使用すると、既存のプロジェクトに簡単に出力キャッシュ処理を追加できます。
- コードのリファクタリングもほとんど行わずにすませられるでしょう。
- </para>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.function">
- <title>Zend_Cache_Frontend_Function</title>
- <sect3 id="zend.cache.frontends.function.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Frontend_Function</classname> は、関数コールの結果をキャッシュします。
- <methodname>call()</methodname> というメソッドを保持しており、
- 関数名とパラメータを配列にしてこのメソッドに渡します。
- </para>
- </sect3>
- <sect3 id="zend.cache.frontends.function.options">
- <title>使用可能なオプション</title>
- <table id="zend.cache.frontends.function.options.table">
- <title>Function フロントエンドのオプション</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>オプション</entry>
- <entry>データ型</entry>
- <entry>デフォルト値</entry>
- <entry>説明</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><emphasis>cache_by_default</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>TRUE</constant></entry>
- <entry>
- <constant>TRUE</constant> の場合は、関数のコール結果がデフォルトでキャッシュされます。
- </entry>
- </row>
- <row>
- <entry><emphasis>cached_functions</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry></entry>
- <entry>
- 常にキャッシュされる関数の名前。
- </entry>
- </row>
- <row>
- <entry><emphasis>non_cached_functions</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry></entry>
- <entry>
- 決してキャッシュされない関数の名前。
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- <sect3 id="zend.cache.frontends.function.examples">
- <title>例</title>
- <para>
- <methodname>call()</methodname> 関数の使用法は、<acronym>PHP</acronym> の
- <methodname>call_user_func_array()</methodname> と同じです。
- </para>
- <programlisting language="php"><![CDATA[
- $cache->call('veryExpensiveFunc', $params);
- // $params は配列です。
- // 例えば、veryExpensiveFunc(1, 'foo', 'bar') のコールをキャッシュするには
- // $cache->call('veryExpensiveFunc', array(1, 'foo', 'bar')) とします。
- ]]></programlisting>
- <para>
- <classname>Zend_Cache_Frontend_Function</classname> は、
- 関数の返り値だけでなく関数内部での出力もキャッシュします。
- </para>
- <note><para>
- <methodname>array()</methodname>、<methodname>echo()</methodname>、<methodname>empty()</methodname>、<methodname>eval()</methodname>、
- <methodname>exit()</methodname>、<methodname>isset()</methodname>、<methodname>list()</methodname>、<methodname>print()</methodname>
- および <methodname>unset()</methodname> 以外なら、
- 任意の組み込み関数やユーザ定義関数を渡すことができます。
- </para></note>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.class">
- <title>Zend_Cache_Frontend_Class</title>
- <sect3 id="zend.cache.frontends.class.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Frontend_Class</classname> は、<classname>Zend_Cache_Frontend_Function</classname>
- と異なり、オブジェクトおよびスタティックメソッドのコールをキャッシュします。
- </para>
- </sect3>
- <sect3 id="zend.cache.frontends.class.options">
- <title>使用可能なオプション</title>
- <table id="zend.cache.frontends.class.options.table">
- <title>Class フロントエンドのオプション</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>オプション</entry>
- <entry>データ型</entry>
- <entry>デフォルト値</entry>
- <entry>説明</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><emphasis>cached_entity</emphasis> (必須)</entry>
- <entry><type>Mixed</type></entry>
- <entry></entry>
- <entry>
- クラス名を設定すると、抽象クラスおよびスタティックコールをキャッシュします。
- オブジェクトを設定すると、そのオブジェクトのメソッドをキャッシュします。
- </entry>
- </row>
- <row>
- <entry><emphasis>cache_by_default</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>TRUE</constant></entry>
- <entry>
- <constant>TRUE</constant> を設定すると、デフォルトでキャッシュされます。
- </entry>
- </row>
- <row>
- <entry><emphasis>cached_methods</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry></entry>
- <entry>
- 常にキャッシュされるメソッドの名前。
- </entry>
- </row>
- <row>
- <entry><emphasis>non_cached_methods</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry></entry>
- <entry>
- 決してキャッシュされないメソッドの名前。
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- <sect3 id="zend.cache.frontends.class.examples">
- <title>例</title>
- <para>
- 例えば、スタティックメソッドのコールをキャッシュするには次のようにします。
- </para>
- <programlisting language="php"><![CDATA[
- class Test {
- // スタティックメソッド
- public static function foobar($param1, $param2) {
- echo "foobar_output($param1, $param2)";
- return "foobar_return($param1, $param2)";
- }
- }
- // [...]
- $frontendOptions = array(
- 'cached_entity' => 'Test' // クラス名を指定します
- );
- // [...]
- // これはキャッシュされます
- $result = $cache->foobar('1', '2');
- ]]></programlisting>
- <para>
- 通常のメソッドのコールをキャッシュするには次のようにします。
- </para>
- <programlisting language="php"><![CDATA[
- class Test {
- private $_string = 'hello !';
- public function foobar2($param1, $param2) {
- echo($this->_string);
- echo "foobar2_output($param1, $param2)";
- return "foobar2_return($param1, $param2)";
- }
- }
- // [...]
- $frontendOptions = array(
- 'cached_entity' => new Test() // クラスのインスタンスを指定します
- );
- // [...]
- // これはキャッシュされます
- $result = $cache->foobar2('1', '2');
- ]]></programlisting>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.file">
- <title>Zend_Cache_Frontend_File</title>
- <sect3 id="zend.cache.frontends.file.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Frontend_File</classname> は、マスタファイルの
- 「更新時刻」にもとづいて動作するフロントエンドです。
- これは、例えば設定ファイルやテンプレートなどで有効に使えるでしょう。
- 複数のマスタファイルを使用することもできます。
- </para>
- <para>
- 例えば、<acronym>XML</acronym> の設定ファイルを使用しており、それが「設定オブジェクト」
- (<classname>Zend_Config</classname> など) を返す関数でパースされるとしましょう。
- <classname>Zend_Cache_Frontend_File</classname> を使用すると、その「設定オブジェクト」
- をキャッシュすることができ (これにより、
- <acronym>XML</acronym> ファイルを毎回パースする必要がなくなります)、さらに「マスタファイル」
- との間で強力な依存性を保持できます。そのため、<acronym>XML</acronym>
- 設定ファイルが更新されると、即時にキャッシュが無効になります。
- </para>
- </sect3>
- <sect3 id="zend.cache.frontends.file.options">
- <title>使用可能なオプション</title>
- <table id="zend.cache.frontends.file.options.table">
- <title>File フロントエンドのオプション</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>オプション</entry>
- <entry>データ型</entry>
- <entry>デフォルト値</entry>
- <entry>説明</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><emphasis>master_file (非推奨)</emphasis></entry>
- <entry><type>String</type></entry>
- <entry>''</entry>
- <entry>
- マスタファイルへのフルパス。
- </entry>
- </row>
- <row>
- <entry><emphasis>master_files</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry><methodname>array()</methodname></entry>
- <entry>
- マスタファイル群へのフルパスの配列。
- </entry>
- </row>
- <row>
- <entry><emphasis>master_files_mode</emphasis></entry>
- <entry><type>String</type></entry>
- <entry><constant>Zend_Cache_Frontend_File::MODE_OR</constant></entry>
- <entry>
- <constant>Zend_Cache_Frontend_File::MODE_AND</constant> あるいは
- <constant>Zend_Cache_Frontend_File::MODE_OR</constant>。
- <constant>MODE_AND</constant> の場合は、
- すべてのマスタファイルにアクセスがあるまでキャッシュが無効化されません。
- <constant>MODE_OR</constant> の場合は、
- どれかひとつのマスタファイルにアクセスがあればキャッシュを無効化します。
- </entry>
- </row>
- <row>
- <entry><emphasis>ignore_missing_master_files</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- <constant>TRUE</constant> の場合は、マスタファイルが存在しない場合は無視します
- (それ以外の場合は例外が発生します)。
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- <sect3 id="zend.cache.frontends.file.examples">
- <title>例</title>
- <para>
- このフロントエンドの使用法は <classname>Zend_Cache_Core</classname> と同じです。
- そのため、特に例は用意していません。唯一しなければならないことは、
- ファクトリを使用する際に、バックエンドのオプションとして
- <emphasis>master_file</emphasis> を設定することだけです。
- </para>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.page">
- <title>Zend_Cache_Frontend_Page</title>
- <sect3 id="zend.cache.frontends.page.introduction">
- <title>導入</title>
- <para>
- <classname>Zend_Cache_Frontend_Page</classname> は <classname>Zend_Cache_Frontend_Output</classname>
- と似ていますが、ページ全体をキャッシュする目的で設計されています。
- <classname>Zend_Cache_Frontend_Page</classname> を使用して、
- ページの一部だけをキャッシュすることはできません。
- </para>
- <para>
- 一方、「キャッシュ ID」は自動的に生成されます。この ID は、
- <varname>$_SERVER['REQUEST_URI']</varname> および (オプションの設定によっては)
- <varname>$_GET</varname>、<varname>$_POST</varname>、<varname>$_SESSION</varname>、
- <varname>$_COOKIE</varname>、<varname>$_FILES</varname> をもとにして生成されます。
- さらに、ひとつのメソッド (<methodname>start()</methodname>) をコールするだけで使用できます。
- <methodname>end()</methodname> は、ページの終了時に自動的にコールされます。
- </para>
- <para>
- 現時点ではまだ実装されていませんが、将来は <acronym>HTTP</acronym> conditional システムを追加する予定です。
- これにより、ネットワークの帯域を節約できるようになります
- (キャッシュにヒットし、かつブラウザがそのバージョンを既に持っている場合に
- <acronym>HTTP</acronym> 304 Not Modified を送信するようにします)。
- </para>
- <!-- TODO : to be translated -->
- <note>
- <para>
- This frontend operates by registering a callback function to be called
- when the output buffering it uses is cleaned. In order for this to operate
- correctly, it must be the final output buffer in the request. To guarantee
- this, the output buffering used by the Dispatcher <emphasis>must</emphasis> be
- disabled by calling <classname>Zend_Controller_Front</classname>'s
- <methodname>setParam()</methodname> method, for example,
- <command>$front->setParam('disableOutputBuffering', true);</command> or adding
- "resources.frontcontroller.params.disableOutputBuffering = true"
- to your bootstrap configuration file (assumed <acronym>INI</acronym>) if using
- <classname>Zend_Application</classname>.
- </para>
- </note>
- </sect3>
- <sect3 id="zend.cache.frontends.page.options">
- <title>使用可能なオプション</title>
- <table id="zend.cache.frontends.page.options.table">
- <title>Page フロントエンドのオプション</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>オプション</entry>
- <entry>データ型</entry>
- <entry>デフォルト値</entry>
- <entry>説明</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><emphasis>http_conditional</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- http_conditional システムを使用します (現時点ではまだ実装されていません)。
- </entry>
- </row>
- <row>
- <entry><emphasis>debug_header</emphasis></entry>
- <entry><type>Boolean</type></entry>
- <entry><constant>FALSE</constant></entry>
- <entry>
- <constant>TRUE</constant> の場合は、キャッシュされた各ページの先頭に
- デバッグ用テキストが追加されます。
- </entry>
- </row>
- <row>
- <entry><emphasis>default_options</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry><methodname>array(...説明を参照ください...)</methodname></entry>
- <entry>
- デフォルトのオプションを表す連想配列です。
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) cache</emphasis> :
- <constant>TRUE</constant> の場合はキャッシュが有効になります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>FALSE</constant>) cache_with_get_variables</emphasis> :
- <constant>TRUE</constant> の場合は、<varname>$_GET</varname> 配列に変数が含まれていてもキャッシュがオンのままになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>FALSE</constant>) cache_with_post_variables</emphasis> :
- <constant>TRUE</constant> の場合は、<varname>$_POST</varname> 配列に変数が含まれていてもキャッシュがオンのままになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>FALSE</constant>) cache_with_session_variables</emphasis> :
- <constant>TRUE</constant> の場合は、<varname>$_SESSION</varname> 配列に変数が含まれていてもキャッシュがオンのままになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>FALSE</constant>) cache_with_files_variables</emphasis> :
- <constant>TRUE</constant> の場合は、<varname>$_FILES</varname> 配列に変数が含まれていてもキャッシュがオンのままになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>FALSE</constant>) cache_with_cookie_variables</emphasis> :
- <constant>TRUE</constant> の場合は、<varname>$_COOKIE</varname> 配列に変数が含まれていてもキャッシュがオンのままになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) make_id_with_get_variables</emphasis> :
- <constant>TRUE</constant> の場合は、キャッシュ ID が <varname>$_GET</varname> 配列の内容に依存するようになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) make_id_with_post_variables</emphasis> :
- <constant>TRUE</constant> の場合は、キャッシュ ID が <varname>$_POST</varname> 配列の内容に依存するようになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) make_id_with_session_variables</emphasis> :
- <constant>TRUE</constant> の場合は、キャッシュ ID が <varname>$_SESSION</varname> 配列の内容に依存するようになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) make_id_with_files_variables</emphasis> :
- <constant>TRUE</constant> の場合は、キャッシュ ID が <varname>$_FILES</varname> 配列の内容に依存するようになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(boolean, デフォルトは <constant>TRUE</constant>) make_id_with_cookie_variables</emphasis> :
- <constant>TRUE</constant> の場合は、キャッシュ ID が <varname>$_COOKIE</varname> 配列の内容に依存するようになります。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(int, デフォルトは <constant>FALSE</constant>) specific_lifetime</emphasis> :
- <constant>FALSE</constant> でない場合は、選択した正規表現に対して指定した有効期限を使用します。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(配列, デフォルトは <methodname>array()</methodname>) tags</emphasis> :
- キャッシュレコード用のタグ。
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>(int, デフォルトは <constant>NULL</constant>) priority</emphasis> :
- 優先度 (バックエンドが優先度をサポートしている場合)。
- </para>
- </listitem>
- </itemizedlist>
- </entry>
- </row>
- <row>
- <entry><emphasis>regexps</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry><methodname>array()</methodname></entry>
- <entry>
- 特定の <constant>REQUEST_URI</constant> に対してのみ適用するオプションを設定する連想配列です。
- キーが (<acronym>PCRE</acronym> の) 正規表現、対応する値は連想配列となります。
- この連想配列には、正規表現が <varname>$_SERVER['REQUEST_URI']</varname>
- にマッチした場合に設定されるオプションを設定します
- (使用可能なオプションについては default_options を参照ください)。
- 複数の正規表現が <varname>$_SERVER['REQUEST_URI']</varname> にマッチした場合は、
- 一番最後にマッチしたもののみが使用されます。
- </entry>
- </row>
- <row>
- <entry><emphasis>memorize_headers</emphasis></entry>
- <entry><type>Array</type></entry>
- <entry><methodname>array()</methodname></entry>
- <entry>
- <acronym>HTTP</acronym> ヘッダ名に対応する文字列の配列です。
- ここにあげられたヘッダがキャッシュデータとともに保存され、
- キャッシュにヒットしたときにそれが "リプレイ" されます。
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- <sect3 id="zend.cache.frontends.page.examples">
- <title>例</title>
- <para>
- <classname>Zend_Cache_Frontend_Page</classname> の使用法は、きわめて簡単です。
- </para>
- <programlisting language="php"><![CDATA[
- // [...] // require、設定そしてファクトリ
- $cache->start();
- // キャッシュにヒットした場合はその結果がブラウザに送信され、
- // 処理はここで停止します
- // ページの残りの部分 ...
- ]]></programlisting>
- <para>
- もう少し複雑な例を見てみましょう。これは、起動ファイル
- (例えば <classname>Zend_Controller</classname> など) 内でキャッシュを集中管理する方法を示したものです。
- </para>
- <programlisting language="php"><![CDATA[
- /*
- * キャッシュセクションの前には、あまり多くの行を書かないようにしましょう。
- * 例えば、処理速度を最適化するためには "require_once" や "Zend_Loader::loadClass"
- * をキャッシュセクションの後におくべきです。
- */
- $frontendOptions = array(
- 'lifetime' => 7200,
- 'debug_header' => true, // デバッグします
- 'regexps' => array(
- // IndexController 全体をキャッシュします
- '^/$' => array('cache' => true),
- // IndexController 全体をキャッシュします
- '^/index/' => array('cache' => true),
- // ArticleController はキャッシュしません
- '^/article/' => array('cache' => false),
- // ……が、ArticleController の "view" アクションはキャッシュします
- '^/article/view/' => array(
- 'cache' => true,
- // また、たとえ $_POST に何らかの変数がふくまれていてもキャッシュを行います
- 'cache_with_post_variables' => true,
- // しかし、そのキャッシュは $_POST 配列に依存します
- 'make_id_with_post_variables' => true
- )
- )
- );
- $backendOptions = array(
- 'cache_dir' => '/tmp/'
- );
- // Zend_Cache_Frontend_Page オブジェクトを取得します
- $cache = Zend_Cache::factory('Page',
- 'File',
- $frontendOptions,
- $backendOptions);
- $cache->start();
- // キャッシュにヒットした場合はその結果がブラウザに送信され、スクリプトの処理はここで停止します。
- // [...] 起動ファイルの終点 (これらの行は、キャッシュにヒットした場合は実行されません)
- ]]></programlisting>
- </sect3>
- <sect3 id="zend.cache.frontends.page.cancel">
- <title>キャンセル用のメソッド</title>
- <para>
- 設計上の理由から、場合によっては (<acronym>HTTP</acronym> 200 以外のコードを使用する場合など)
- 現在のキャッシュ処理をキャンセルする必要が生じることもあります。
- そこで、このフロントエンド用に <methodname>cancel()</methodname> メソッドを用意しました。
- </para>
- <programlisting language="php"><![CDATA[
- // [...] // require, configuration そして factory
- $cache->start();
- // [...]
- if ($someTest) {
- $cache->cancel();
- // [...]
- }
- // [...]
- ]]></programlisting>
- </sect3>
- </sect2>
- <sect2 id="zend.cache.frontends.capture">
- <title>Zend_Cache_Frontend_Capture</title>
- <sect3 id="zend.cache.frontends.capture.introduction">
- <title>導入</title>
- <!-- TODO : to be translated -->
- <para>
- <classname>Zend_Cache_Frontend_Capture</classname> is like
- <classname>Zend_Cache_Frontend_Output</classname> but designed for a complete page.
- It's impossible to use <classname>Zend_Cache_Frontend_Capture</classname> for
- caching only a single block. This class is specifically designed to operate in
- concert only with the <classname>Zend_Cache_Backend_Static</classname> backend to
- assist in caching entire pages of <acronym>HTML</acronym> / <acronym>XML</acronym>
- or other content to a physical static file on the local filesystem.
- </para>
- <para>
- Please refer to the documentation on
- <classname>Zend_Cache_Backend_Static</classname> for all use cases pertaining to
- this class.
- </para>
- <note>
- <para>
- This frontend operates by registering a callback function to be called
- when the output buffering it uses is cleaned. In order for this to operate
- correctly, it must be the final output buffer in the request. To guarantee
- this, the output buffering used by the Dispatcher <emphasis>must</emphasis> be
- disabled by calling <classname>Zend_Controller_Front</classname>'s
- <methodname>setParam()</methodname> method, for example,
- <command>$front->setParam('disableOutputBuffering', true);</command> or adding
- "resources.frontcontroller.params.disableOutputBuffering = true"
- to your bootstrap configuration file (assumed <acronym>INI</acronym>) if using
- <classname>Zend_Application</classname>.
- </para>
- </note>
- </sect3>
- </sect2>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|