Zend_Cache-Backends.xml 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 23148 -->
  4. <sect1 id="zend.cache.backends">
  5. <title><classname>Zend_Cache</classname> のバックエンド</title>
  6. <para>
  7. バックエンドには、標準と拡張の 2 種類があります。
  8. もちろん、拡張バックエンドのほうがより高機能となります。
  9. </para>
  10. <sect2 id="zend.cache.backends.file">
  11. <title>Zend_Cache_Backend_File</title>
  12. <para>
  13. この (拡張) バックエンドは、キャッシュレコードを
  14. (指定したディレクトリの) ファイルに保存します。
  15. </para>
  16. <para>
  17. 使用可能なオプションは次のとおりです。
  18. </para>
  19. <table id="zend.cache.backends.file.table">
  20. <title>File バックエンドのオプション</title>
  21. <tgroup cols="4">
  22. <thead>
  23. <row>
  24. <entry>オプション</entry>
  25. <entry>データ型</entry>
  26. <entry>デフォルト値</entry>
  27. <entry>説明</entry>
  28. </row>
  29. </thead>
  30. <tbody>
  31. <row>
  32. <entry><emphasis>cache_dir</emphasis></entry>
  33. <entry><type>String</type></entry>
  34. <entry>[system temp dir]</entry>
  35. <entry>
  36. キャッシュファイルを書き込むディレクトリ。
  37. </entry>
  38. </row>
  39. <row>
  40. <entry><emphasis>file_locking</emphasis></entry>
  41. <entry><type>Boolean</type></entry>
  42. <entry><constant>TRUE</constant></entry>
  43. <entry>
  44. ファイルロックを有効/無効にします。
  45. 不慮の事故でキャッシュが破壊されることを防げますが、
  46. マルチスレッドなウェブサーバ環境や <acronym>NFS</acronym> ファイルシステム上では役に立ちません。
  47. </entry>
  48. </row>
  49. <row>
  50. <entry><emphasis>read_control</emphasis></entry>
  51. <entry><type>Boolean</type></entry>
  52. <entry><constant>TRUE</constant></entry>
  53. <entry>
  54. 読み込み制御を有効/無効にします。有効にすると
  55. キャッシュファイルに制御キーが埋め込まれます。
  56. キャッシュの読み込み後、計算した結果とキャッシュのキーを比較します。
  57. </entry>
  58. </row>
  59. <row>
  60. <entry><emphasis>read_control_type</emphasis></entry>
  61. <entry><type>String</type></entry>
  62. <entry>'crc32'</entry>
  63. <entry>
  64. 読み込み制御の方式 (読み込み制御が有効な場合にのみ使用します)。
  65. 使用可能な値は
  66. 'md5' (一番安全だが、最も遅い)、
  67. 'crc32' (安全性には劣るが、より高速。悪くない選択肢です)、
  68. 'adler32' (新たな選択肢。crc32 より高速です)、
  69. 'strlen' (最も高速。長さのみをチェックします)
  70. のいずれかです。
  71. </entry>
  72. </row>
  73. <row>
  74. <entry><emphasis>hashed_directory_level</emphasis></entry>
  75. <entry><type>Integer</type></entry>
  76. <entry>0</entry>
  77. <entry>
  78. ディレクトリ構造のレベルを指定します。0 は "ディレクトリ階層を作らない"、
  79. 1 は "一段階のサブディレクトリを作る"、2 は "二段階の……" を意味します。
  80. 何千ものキャッシュファイルを使用する場合にのみ、
  81. このオプションによる高速化を実感できるでしょう。
  82. 適切な設定値を決めるには、実際にベンチマークを取得するしかありません。
  83. たいていの場合は 1 または 2 でよいでしょう。
  84. </entry>
  85. </row>
  86. <row>
  87. <entry><emphasis>hashed_directory_umask</emphasis></entry>
  88. <entry><type>Integer</type></entry>
  89. <entry>0700</entry>
  90. <entry>
  91. ディレクトリ構造の umask を指定します。
  92. </entry>
  93. </row>
  94. <row>
  95. <entry><emphasis>file_name_prefix</emphasis></entry>
  96. <entry><type>String</type></entry>
  97. <entry>'zend_cache'</entry>
  98. <entry>
  99. キャッシュファイルのプレフィックスを設定します。
  100. このオプションを設定する際には十分注意しましょう。
  101. あまりにもありふれた値をシステムのキャッシュディレクトリ
  102. (<filename>/tmp</filename> など) で使用すると、
  103. キャッシュの削除の際に余計なものまで削除されてしまうはめになります。
  104. </entry>
  105. </row>
  106. <row>
  107. <entry><emphasis>cache_file_umask</emphasis></entry>
  108. <entry><type>Integer</type></entry>
  109. <entry>0700</entry>
  110. <entry>
  111. キャッシュファイルの umask を設定します。
  112. </entry>
  113. </row>
  114. <row>
  115. <entry><emphasis>metatadatas_array_max_size</emphasis></entry>
  116. <entry><type>Integer</type></entry>
  117. <entry>100</entry>
  118. <entry>
  119. メタデータ配列の内部最大サイズを設定します
  120. (よくわからない場合はこの値を変更してはいけません)。
  121. </entry>
  122. </row>
  123. </tbody>
  124. </tgroup>
  125. </table>
  126. </sect2>
  127. <sect2 id="zend.cache.backends.sqlite">
  128. <title>Zend_Cache_Backend_Sqlite</title>
  129. <para>
  130. この (拡張) バックエンドは、キャッシュレコードを
  131. SQLite データベースに保存します。
  132. </para>
  133. <para>
  134. 使用可能なオプションは次のとおりです。
  135. </para>
  136. <table id="zend.cache.backends.sqlite.table">
  137. <title>Sqlite バックエンドのオプション</title>
  138. <tgroup cols="4">
  139. <thead>
  140. <row>
  141. <entry>オプション</entry>
  142. <entry>データ型</entry>
  143. <entry>デフォルト値</entry>
  144. <entry>説明</entry>
  145. </row>
  146. </thead>
  147. <tbody>
  148. <row>
  149. <entry><emphasis>cache_db_complete_path (必須)</emphasis></entry>
  150. <entry><type>String</type></entry>
  151. <entry><constant>NULL</constant></entry>
  152. <entry>
  153. SQLite データベースへの (ファイル名も含めた) フルパス。
  154. </entry>
  155. </row>
  156. <row>
  157. <entry><emphasis>automatic_vacuum_factor</emphasis></entry>
  158. <entry><type>Integer</type></entry>
  159. <entry>10</entry>
  160. <entry>
  161. 自動バキューム処理の設定を行います。
  162. 自動バキューム処理とは、<methodname>clean()</methodname> や <methodname>delete()</methodname>
  163. がコールされた際に自動的にデータベースの断片化解消を行う
  164. (そしてサイズを縮小する) ことです。
  165. 0 を指定すると、自動バキュームを行いません。
  166. 1 を指定すると (<methodname>delete()</methodname> や <methodname>clean()</methodname>
  167. がコールされると) そのたびにバキュームを行います。
  168. x (1 より大きな整数) を指定すると、
  169. <methodname>clean()</methodname> や <methodname>delete()</methodname> が x 回コールされるたびに
  170. 一回の頻度でランダムに自動バキュームを行います。
  171. </entry>
  172. </row>
  173. </tbody>
  174. </tgroup>
  175. </table>
  176. </sect2>
  177. <sect2 id="zend.cache.backends.memcached">
  178. <title>Zend_Cache_Backend_Memcached</title>
  179. <para>
  180. この (拡張) バックエンドは、キャッシュレコードを memcached サーバに保存します。
  181. <ulink url="http://www.danga.com/memcached/">memcached</ulink> は、
  182. 高性能な分散メモリオブジェクトキャッシュシステムです。このバックエンドを使用するには、
  183. memcached デーモンおよび
  184. <ulink url="http://pecl.php.net/package/memcache">memcache <acronym>PECL</acronym> 拡張モジュール</ulink>
  185. が必要です。
  186. </para>
  187. <para>
  188. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  189. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  190. </para>
  191. <para>
  192. 使用可能なオプションは次のとおりです。
  193. </para>
  194. <table id="zend.cache.backends.memcached.table">
  195. <title>Memcached バックエンドのオプション</title>
  196. <tgroup cols="4">
  197. <thead>
  198. <row>
  199. <entry>オプション</entry>
  200. <entry>データ型</entry>
  201. <entry>デフォルト値</entry>
  202. <entry>説明</entry>
  203. </row>
  204. </thead>
  205. <tbody>
  206. <row>
  207. <entry><emphasis>servers</emphasis></entry>
  208. <entry><type>Array</type></entry>
  209. <entry>
  210. <command>array(array('host' => 'localhost', 'port' => 11211,
  211. 'persistent' => true, 'weight' => 1, 'timeout' => 5,
  212. 'retry_interval' => 15, 'status' => true,
  213. 'failure_callback' => '' ))</command>
  214. </entry>
  215. <entry>
  216. memcached サーバの配列です。各 memcached サーバの情報は、
  217. 以下のような連想配列で指定します。
  218. 'host' => (string) : memcached サーバのサーバ名
  219. 'port' => (int) : memcached サーバのポート番号
  220. 'persistent' => (bool) : この memcached サーバに対して持続的な接続を使用するかどうか
  221. 'weight' => (int) : memcached サーバの重み付け
  222. 'timeout' => (int) : memcached サーバのタイムアウト
  223. 'retry_interval' => (int) : memcached サーバの再試行間隔
  224. 'status' => (bool) : memcached サーバのステータス
  225. 'failure_callback' => (callback) : memcached サーバのコールバック関数
  226. </entry>
  227. </row>
  228. <row>
  229. <entry><emphasis>compression</emphasis></entry>
  230. <entry><type>Boolean</type></entry>
  231. <entry><constant>FALSE</constant></entry>
  232. <entry>
  233. その場での圧縮処理を行いたい場合に <constant>TRUE</constant> を指定します。
  234. </entry>
  235. </row>
  236. <row>
  237. <entry><emphasis>compatibility</emphasis></entry>
  238. <entry><type>Boolean</type></entry>
  239. <entry><constant>FALSE</constant></entry>
  240. <entry>
  241. 古い memcache サーバ/拡張モジュールとの互換性モードを使用したい場合に
  242. <constant>TRUE</constant> を指定します。
  243. </entry>
  244. </row>
  245. </tbody>
  246. </tgroup>
  247. </table>
  248. </sect2>
  249. <sect2 id="zend.cache.backends.libmemcached">
  250. <title>Zend_Cache_Backend_Libmemcached</title>
  251. <para>
  252. This (extended) backend stores cache records into a memcached server. <ulink
  253. url="http://www.danga.com/memcached/">memcached</ulink> is a high-performance,
  254. distributed memory object caching system. To use this backend, you need a memcached
  255. daemon and <ulink url="http://pecl.php.net/package/memcached">the memcached
  256. <acronym>PECL</acronym> extension</ulink>.
  257. </para>
  258. <para>
  259. Be careful : with this backend, "tags" are not supported for the moment as
  260. the "doNotTestCacheValidity=true" argument.
  261. </para>
  262. <para>
  263. Available options are :
  264. </para>
  265. <table id="zend.cache.backends.libmemcached.table">
  266. <title>Libmemcached Backend Options</title>
  267. <tgroup cols="4">
  268. <thead>
  269. <row>
  270. <entry>Option</entry>
  271. <entry>Data Type</entry>
  272. <entry>Default Value</entry>
  273. <entry>Description</entry>
  274. </row>
  275. </thead>
  276. <tbody>
  277. <row>
  278. <entry><emphasis>servers</emphasis></entry>
  279. <entry><type>Array</type></entry>
  280. <entry>
  281. <command>array(array('host' => 'localhost', 'port' => 11211,
  282. 'weight' => 1))</command>
  283. </entry>
  284. <entry>
  285. An array of memcached servers ; each memcached server is described by
  286. an associative array:
  287. 'host' => (string) : the name of the memcached server,
  288. 'port' => (int) : the port of the memcached server,
  289. 'weight' => (int) :the weight of the memcached server
  290. </entry>
  291. </row>
  292. <row>
  293. <entry><emphasis>client</emphasis></entry>
  294. <entry><type>Array</type></entry>
  295. <entry>
  296. <command>array(
  297. Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
  298. Memcached::OPT_HASH => Memcached::HASH_MD5,
  299. Memcached::OPT_LIBKETAMA_COMPATIBLE => true
  300. )</command>
  301. </entry>
  302. <entry>
  303. An associative array of memcached client options ;
  304. The array key can be the name of the memcached option constant
  305. (without 'OPT_') or the integer value of it.
  306. See <ulink url="http://php.net/manual/memcached.constants.php">
  307. Memcached constants on <acronym>PHP</acronym> manual</ulink>
  308. </entry>
  309. </row>
  310. </tbody>
  311. </tgroup>
  312. </table>
  313. </sect2>
  314. <sect2 id="zend.cache.backends.apc">
  315. <title>Zend_Cache_Backend_Apc</title>
  316. <para>
  317. この (拡張) バックエンドは、キャッシュレコードを共有メモリに保存する際に
  318. <ulink url="http://pecl.php.net/package/APC">APC</ulink> (Alternative <acronym>PHP</acronym> Cache)
  319. 拡張モジュールを使用します
  320. (当然、このバックエンドを使用するにはこの拡張モジュールが必要です)。
  321. </para>
  322. <para>
  323. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  324. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  325. </para>
  326. <para>
  327. このバックエンドではオプションを使用しません。
  328. </para>
  329. </sect2>
  330. <sect2 id="zend.cache.backends.xcache">
  331. <title>Zend_Cache_Backend_Xcache</title>
  332. <para>
  333. このバックエンドは、キャッシュレコードを共有メモリに保存する際に
  334. <ulink url="http://xcache.lighttpd.net/">XCache</ulink>
  335. 拡張モジュールを使用します
  336. (当然、このバックエンドを使うにはこの拡張モジュールが必要となります)。
  337. </para>
  338. <para>
  339. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  340. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  341. </para>
  342. <para>
  343. 使用可能なオプションは次のとおりです。
  344. </para>
  345. <table id="zend.cache.backends.xcache.table">
  346. <title>Xcache バックエンドのオプション</title>
  347. <tgroup cols="4">
  348. <thead>
  349. <row>
  350. <entry>オプション</entry>
  351. <entry>データ型</entry>
  352. <entry>デフォルト値</entry>
  353. <entry>説明</entry>
  354. </row>
  355. </thead>
  356. <tbody>
  357. <row>
  358. <entry><emphasis>user</emphasis></entry>
  359. <entry><type>String</type></entry>
  360. <entry><constant>NULL</constant></entry>
  361. <entry>
  362. <filename>xcache.admin.user</filename> です。
  363. <methodname>clean()</methodname> メソッドを使う際に必要です。
  364. </entry>
  365. </row>
  366. <row>
  367. <entry><emphasis>password</emphasis></entry>
  368. <entry><type>String</type></entry>
  369. <entry><constant>NULL</constant></entry>
  370. <entry>
  371. <filename>xcache.admin.pass</filename> (<acronym>MD5</acronym> ではない平文形式) です。
  372. <methodname>clean()</methodname> メソッドを使う際に必要です。
  373. </entry>
  374. </row>
  375. </tbody>
  376. </tgroup>
  377. </table>
  378. </sect2>
  379. <sect2 id="zend.cache.backends.platform">
  380. <title>Zend_Cache_Backend_ZendPlatform</title>
  381. <para>
  382. このバックエンドは、<ulink url="http://www.zend.co.jp/product/zendplatform.html">Zend Platform</ulink>
  383. 製品のコンテンツキャッシング <acronym>API</acronym> を使用します。当然、このバックエンドを使用するには
  384. Zend Platform をインストールする必要があります。
  385. </para>
  386. <para>
  387. このバックエンドはタグをサポートしています。しかし、
  388. クリーニングモード <constant>CLEANING_MODE_NOT_MATCHING_TAG</constant> はサポートしていません。
  389. </para>
  390. <para>
  391. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  392. 'Zend' と 'Platform' の間に区切り文字を入れます。区切り文字としては
  393. '-'、'.'、' ' あるいは '_' が使用できます。
  394. </para>
  395. <programlisting language="php"><![CDATA[
  396. $cache = Zend_Cache::factory('Core', 'Zend Platform');
  397. ]]></programlisting>
  398. <para>
  399. このバックエンドではオプションを使用しません。
  400. </para>
  401. </sect2>
  402. <sect2 id="zend.cache.backends.twolevels">
  403. <title>Zend_Cache_Backend_TwoLevels</title>
  404. <para>
  405. この (拡張) バックエンドは複合型です。
  406. キャッシュレコードを、
  407. 高速 (だが制限付き) な Apc、Memcache…… および "低速"
  408. な File、Sqlite…… の 2 種類の別々のバックエンドに格納します。
  409. </para>
  410. <para>
  411. このバックエンドは priority パラメータを使用 (フロントエンドレベルで、記録開始時に指定)
  412. し、高速バックエンドの残りのスペースを用いてふたつのバックエンドの使用を最適化します。
  413. </para>
  414. <para>
  415. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  416. 'Two' と 'Levels' の間に区切り文字を入れます。区切り文字としては
  417. '-'、'.'、' ' あるいは '_' が使用できます。
  418. </para>
  419. <programlisting language="php"><![CDATA[
  420. $cache = Zend_Cache::factory('Core', 'Two Levels');
  421. ]]></programlisting>
  422. <para>
  423. 使用可能なオプションは次のとおりです。
  424. </para>
  425. <table id="zend.cache.backends.twolevels.table">
  426. <title>TwoLevels バックエンドのオプション</title>
  427. <tgroup cols="4">
  428. <thead>
  429. <row>
  430. <entry>オプション</entry>
  431. <entry>データ型</entry>
  432. <entry>デフォルト値</entry>
  433. <entry>説明</entry>
  434. </row>
  435. </thead>
  436. <tbody>
  437. <row>
  438. <entry><emphasis>slow_backend</emphasis></entry>
  439. <entry><type>String</type></entry>
  440. <entry>File</entry>
  441. <entry>
  442. "低速" バックエンドの名前。
  443. </entry>
  444. </row>
  445. <row>
  446. <entry><emphasis>fast_backend</emphasis></entry>
  447. <entry><type>String</type></entry>
  448. <entry>Apc</entry>
  449. <entry>
  450. "高速" バックエンドの名前。
  451. </entry>
  452. </row>
  453. <row>
  454. <entry><emphasis>slow_backend_options</emphasis></entry>
  455. <entry><type>Array</type></entry>
  456. <entry><methodname>array()</methodname></entry>
  457. <entry>
  458. "低速" バックエンドのオプション。
  459. </entry>
  460. </row>
  461. <row>
  462. <entry><emphasis>fast_backend_options</emphasis></entry>
  463. <entry><type>Array</type></entry>
  464. <entry><methodname>array()</methodname></entry>
  465. <entry>
  466. "高速" バックエンドのオプション。
  467. </entry>
  468. </row>
  469. <row>
  470. <entry><emphasis>slow_backend_custom_naming</emphasis></entry>
  471. <entry><type>Boolean</type></entry>
  472. <entry><constant>FALSE</constant></entry>
  473. <entry>
  474. <constant>TRUE</constant> の場合は、引数 slow_backend を完全なクラス名として使用します。
  475. <constant>FALSE</constant> の場合は、引数をクラス名 "<classname>Zend_Cache_Backend_</classname>[...]"
  476. の最後の部分として使用します。
  477. </entry>
  478. </row>
  479. <row>
  480. <entry><emphasis>fast_backend_custom_naming</emphasis></entry>
  481. <entry><type>Boolean</type></entry>
  482. <entry><constant>FALSE</constant></entry>
  483. <entry>
  484. <constant>TRUE</constant> の場合は、引数 fast_backend を完全なクラス名として使用します。
  485. <constant>FALSE</constant> の場合は、引数をクラス名 "<classname>Zend_Cache_Backend_</classname>[...]"
  486. の最後の部分として使用します。
  487. </entry>
  488. </row>
  489. <row>
  490. <entry><emphasis>slow_backend_autoload</emphasis></entry>
  491. <entry><type>Boolean</type></entry>
  492. <entry><constant>FALSE</constant></entry>
  493. <entry>
  494. <constant>TRUE</constant> の場合は、低速バックエンドに対して require_once を行いません
  495. (独自のバックエンドを使用する場合にのみ有用です)。
  496. </entry>
  497. </row>
  498. <row>
  499. <entry><emphasis>fast_backend_autoload</emphasis></entry>
  500. <entry><type>Boolean</type></entry>
  501. <entry><constant>FALSE</constant></entry>
  502. <entry>
  503. <constant>TRUE</constant> の場合は、高速バックエンドに対して require_once を行いません
  504. (独自のバックエンドを使用する場合にのみ有用です)。
  505. </entry>
  506. </row>
  507. <row>
  508. <entry><emphasis>auto_refresh_fast_cache</emphasis></entry>
  509. <entry><type>Boolean</type></entry>
  510. <entry><constant>TRUE</constant></entry>
  511. <entry>
  512. <constant>TRUE</constant> の場合は、キャッシュレコードにヒットしたときに
  513. 高速キャッシュを自動的にリフレッシュします。
  514. </entry>
  515. </row>
  516. <row>
  517. <entry><emphasis>stats_update_factor</emphasis></entry>
  518. <entry><type>Integer</type></entry>
  519. <entry>10</entry>
  520. <entry>
  521. 高速バックエンドを使用率の計算を無効化 / 効率化します
  522. (レコードをキャッシュに書き込む際の
  523. 高速バックエンド使用率の計算は、
  524. キャッシュ書き込み x 回につき 1 回の割合でランダムに行われます)。
  525. </entry>
  526. </row>
  527. </tbody>
  528. </tgroup>
  529. </table>
  530. </sect2>
  531. <sect2 id="zend.cache.backends.zendserver">
  532. <title>Zend_Cache_Backend_ZendServer_Disk および Zend_Cache_Backend_ZendServer_ShMem</title>
  533. <para>
  534. これらのバックエンドは、キャッシュレコードの保存に
  535. <ulink url="http://www.zend.com/en/products/server/downloads-all?zfs=zf_download">Zend Server</ulink>
  536. のキャッシュ機能を使用します。
  537. </para>
  538. <para>
  539. 注意: このバックエンドでは、今のところ "タグ" がサポートされていません。
  540. また、引数 "doNotTestCacheValidity=true" もサポートされていません。
  541. </para>
  542. <para>
  543. これらのバックエンドが動作するのは、Zend Server 環境で
  544. <acronym>HTTP</acronym> あるいは <acronym>HTTPS</acronym>
  545. 越しにページをリクエストした場合のみです。
  546. コマンドラインでスクリプトを実行した場合は動作しません。
  547. </para>
  548. <para>
  549. <methodname>Zend_Cache::factory()</methodname> メソッドでこのバックエンドを指定する場合は、
  550. パラメータ <emphasis>customBackendNaming</emphasis> を <constant>TRUE</constant> とします。
  551. </para>
  552. <programlisting language="php"><![CDATA[
  553. $cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_ZendServer_Disk',
  554. $frontendOptions, $backendOptions, false, true);
  555. ]]></programlisting>
  556. <para>
  557. このバックエンドにはオプションはありません。
  558. </para>
  559. </sect2>
  560. <sect2 id="zend.cache.backends.static">
  561. <title>Zend_Cache_Backend_Static</title>
  562. <para>
  563. This backend works in concert with <classname>
  564. Zend_Cache_Frontend_Capture</classname> (the two must be used
  565. together) to save the output from requests as static files. This
  566. means the static files are served directly on subsequent requests
  567. without any involvement of PHP or the Zend Framework at all.
  568. </para>
  569. <note>
  570. <para>
  571. <classname>Zend_Cache_Frontend_Capture</classname> operates
  572. by registering a callback function to be called
  573. when the output buffering it uses is cleaned. In order for this to operate
  574. correctly, it must be the final output buffer in the request. To guarantee
  575. this, the output buffering used by the Dispatcher <emphasis>must</emphasis> be
  576. disabled by calling <classname>Zend_Controller_Front</classname>'s
  577. <methodname>setParam()</methodname> method, for example,
  578. <command>$front->setParam('disableOutputBuffering', true);</command> or adding
  579. "resources.frontcontroller.params.disableOutputBuffering = true"
  580. to your bootstrap configuration file (assumed <acronym>INI</acronym>) if using
  581. <classname>Zend_Application</classname>.
  582. </para>
  583. </note>
  584. <para>
  585. The benefits of this cache include a large throughput increase since
  586. all subsequent requests return the static file and don't need any
  587. dynamic processing. Of course this also has some disadvantages. The
  588. only way to retry the dynamic request is to purge the cached file
  589. from elsewhere in the application (or via a cronjob if timed). It
  590. is also restricted to single-server applications where only one
  591. filesystem is used. Nevertheless, it can be a powerful means of
  592. getting more performance without incurring the cost of a proxy on
  593. single machines.
  594. </para>
  595. <para>
  596. Before describing its options, you should note this needs some
  597. changes to the default .htaccess file in order for requests to be
  598. directed to the static files if they exist. Here's an example of
  599. a simple application caching some content, including two specific
  600. feeds which need additional treatment to serve a correct
  601. Content-Type header:
  602. </para>
  603. <programlisting language="text"><![CDATA[
  604. AddType application/rss+xml .xml
  605. AddType application/atom+xml .xml
  606. RewriteEngine On
  607. RewriteCond %{REQUEST_URI} feed/rss$
  608. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  609. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/rss+xml]
  610. RewriteCond %{REQUEST_URI} feed/atom$
  611. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  612. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/atom+xml]
  613. RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
  614. RewriteRule ^/*$ cached/index.html [L]
  615. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.(html|xml|json|opml|svg) -f
  616. RewriteRule .* cached/%{REQUEST_URI}.%1 [L]
  617. RewriteCond %{REQUEST_FILENAME} -s [OR]
  618. RewriteCond %{REQUEST_FILENAME} -l [OR]
  619. RewriteCond %{REQUEST_FILENAME} -d
  620. RewriteRule ^.*$ - [NC,L]
  621. RewriteRule ^.*$ index.php [NC,L]
  622. ]]></programlisting>
  623. <para>
  624. The above assumes static files are cached to the directory ./public/cached.
  625. We'll cover the option setting this location, "public_dir", below.
  626. </para>
  627. <para>
  628. Due to the nature of static file caching, the backend class offers two
  629. additional methods: <methodname>remove()</methodname> and <methodname>
  630. removeRecursively()</methodname>. Both accept a request URI, which when
  631. mapped to the "public_dir" where static files are cached, and has a
  632. pre-stored extension appended, provides the name of either a static
  633. file to delete, or a directory path to delete recursively. Due to the
  634. restraints of <classname>Zend_Cache_Backend_Interface</classname>, all
  635. other methods such as <classname>save()</classname> accept an ID which
  636. is calculated by applying bin2hex() to a request URI.
  637. </para>
  638. <para>
  639. Given the level at which static caching operates, static file caching
  640. is addressed for simpler use with the <classname>
  641. Zend_Controller_Action_Helper_Cache</classname> action helper. This helper
  642. assists in setting which actions of a controller to cache, with what tags,
  643. and with which extension. It also offers methods for purging the cache by
  644. request URI or tag. Static file caching is also assisted by <classname>
  645. Zend_Cache_Manager</classname> which includes pre-configured configuration
  646. templates for a static cache (as Zend_Cache_Manager::PAGECACHE or "page").
  647. The defaults therein can be configured as needed to set up a "public_dir"
  648. location for caching, etc.
  649. </para>
  650. <note>
  651. <para>
  652. It should be noted that the static cache actually uses a secondary
  653. cache to store tags (obviously we can't store them elsewhere since
  654. a static cache does not invoke PHP if working correctly). This is
  655. just a standard Core cache, and should use a persistent backend such
  656. as File or TwoLevels (to take advantage of memory storage without
  657. sacrificing permanent persistance). The backend includes the option
  658. "tag_cache" to set this up (it is obligatory), or the <methodname>
  659. setInnerCache()</methodname> method.
  660. </para>
  661. </note>
  662. <table id="zend.cache.backends.static.table">
  663. <title>Static Backend Options</title>
  664. <tgroup cols="4">
  665. <thead>
  666. <row>
  667. <entry>Option</entry>
  668. <entry>Data Type</entry>
  669. <entry>Default Value</entry>
  670. <entry>Description</entry>
  671. </row>
  672. </thead>
  673. <tbody>
  674. <row>
  675. <entry><emphasis>public_dir</emphasis></entry>
  676. <entry><type>String</type></entry>
  677. <entry>NULL</entry>
  678. <entry>
  679. Directory where to store static files. This must exist
  680. in your public directory.
  681. </entry>
  682. </row>
  683. <row>
  684. <entry><emphasis>file_locking</emphasis></entry>
  685. <entry><type>Boolean</type></entry>
  686. <entry><constant>TRUE</constant></entry>
  687. <entry>
  688. Enable or disable file_locking : Can avoid cache corruption under
  689. bad circumstances but it doesn't help on multithread webservers
  690. or on <acronym>NFS</acronym> filesystems...
  691. </entry>
  692. </row>
  693. <row>
  694. <entry><emphasis>read_control</emphasis></entry>
  695. <entry><type>Boolean</type></entry>
  696. <entry><constant>TRUE</constant></entry>
  697. <entry>
  698. Enable / disable read control : if enabled, a control key is
  699. embedded in the cache file and this key is compared with the
  700. one calculated after the reading.
  701. </entry>
  702. </row>
  703. <row>
  704. <entry><emphasis>read_control_type</emphasis></entry>
  705. <entry><type>String</type></entry>
  706. <entry>'crc32'</entry>
  707. <entry>
  708. Type of read control (only if read control is enabled). Available values
  709. are : 'md5' (best but slowest), 'crc32' (lightly less safe but faster,
  710. better choice), 'adler32' (new choice, faster than crc32),
  711. 'strlen' for a length only test (fastest).
  712. </entry>
  713. </row>
  714. <row>
  715. <entry><emphasis>cache_file_umask</emphasis></entry>
  716. <entry><type>Integer</type></entry>
  717. <entry>0700</entry>
  718. <entry>
  719. umask for cached files.
  720. </entry>
  721. </row>
  722. <row>
  723. <entry><emphasis>cache_directory_umask</emphasis></entry>
  724. <entry><type>Integer</type></entry>
  725. <entry>0700</entry>
  726. <entry>
  727. Umask for directories created within public_dir.
  728. </entry>
  729. </row>
  730. <row>
  731. <entry><emphasis>file_extension</emphasis></entry>
  732. <entry><type>String</type></entry>
  733. <entry>'.html'</entry>
  734. <entry>
  735. Default file extension for static files created. This
  736. can be configured on the fly, see <methodname>
  737. Zend_Cache_Backend_Static::save()</methodname> though
  738. generally it's recommended to rely on <classname>
  739. Zend_Controller_Action_Helper_Cache</classname> when
  740. doing so since it's simpler that way than messing with
  741. arrays/serialization manually.
  742. </entry>
  743. </row>
  744. <row>
  745. <entry><emphasis>index_filename</emphasis></entry>
  746. <entry><type>String</type></entry>
  747. <entry>'index'</entry>
  748. <entry>
  749. If a request URI does not contain sufficient information
  750. to construct a static file (usually this means an index
  751. call, e.g. URI of '/'), the index_filename is used instead.
  752. So '' or '/' would map to 'index.html' (assuming the default
  753. file_extension is '.html').
  754. </entry>
  755. </row>
  756. <row>
  757. <entry><emphasis>tag_cache</emphasis></entry>
  758. <entry><type>Object</type></entry>
  759. <entry>NULL</entry>
  760. <entry>
  761. Used to set an 'inner' cache utilised to store tags
  762. and file extensions associated with static files. This
  763. MUST be set or the static cache cannot be tracked and
  764. managed.
  765. </entry>
  766. </row>
  767. <row>
  768. <entry><emphasis>disable_caching</emphasis></entry>
  769. <entry><type>Boolean</type></entry>
  770. <entry>FALSE</entry>
  771. <entry>
  772. If set to TRUE, static files will not be cached. This
  773. will force all requests to be dynamic even if marked
  774. to be cached in Controllers. Useful for debugging.
  775. </entry>
  776. </row>
  777. </tbody>
  778. </tgroup>
  779. </table>
  780. </sect2>
  781. </sect1>
  782. <!--
  783. vim:se ts=4 sw=4 et:
  784. -->