Zend_Cache-Backends.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- EN-Revision: 22140 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.cache.backends">
  5. <title>Les backends Zend_Cache</title>
  6. <para>
  7. Il existe deux types de backends&#160;: les standards et les étendus. Bien sûr, les
  8. backends étendus offrent des fonctionnalités supplémentaires.
  9. </para>
  10. <sect2 id="zend.cache.backends.file">
  11. <title>Zend_Cache_Backend_File</title>
  12. <para>
  13. Ces backends (étendus) stockent les enregistrements de cache dans des fichiers
  14. (dans un dossier choisi).
  15. </para>
  16. <para>Les options disponibles sont&#160;:</para>
  17. <table id="zend.cache.backends.file.table">
  18. <title>Options du backend File</title>
  19. <tgroup cols="4">
  20. <thead>
  21. <row>
  22. <entry>Option</entry>
  23. <entry>Type de données</entry>
  24. <entry>Valeur par défaut</entry>
  25. <entry>Description</entry>
  26. </row>
  27. </thead>
  28. <tbody>
  29. <row>
  30. <entry><emphasis>cache_dir</emphasis></entry>
  31. <entry><type>String</type></entry>
  32. <entry><filename>/tmp/</filename></entry>
  33. <entry>Répertoire où stocker les fichiers de cache</entry>
  34. </row>
  35. <row>
  36. <entry><emphasis>file_locking</emphasis></entry>
  37. <entry><type>Boolean</type></entry>
  38. <entry><constant>TRUE</constant></entry>
  39. <entry>
  40. Active / désactive le verrou de fichier&#160;: peut éviter la
  41. corruption du cache dans de mauvaises circonstances, mais il n'aide en
  42. rien sur des serveur multithreadés ou sur des systèmes de fichier
  43. <acronym>NFS</acronym>...
  44. </entry>
  45. </row>
  46. <row>
  47. <entry><emphasis>read_control</emphasis></entry>
  48. <entry><type>Boolean</type></entry>
  49. <entry><constant>TRUE</constant></entry>
  50. <entry>
  51. Active / désactive le contrôle de lecture&#160;: si activé, une clé
  52. de contrôle est embarquée dans le fichier de cache et cette clé est
  53. comparée avec celle calculée après la lecture.
  54. </entry>
  55. </row>
  56. <row>
  57. <entry><emphasis>read_control_type</emphasis></entry>
  58. <entry><type>String</type></entry>
  59. <entry>'crc32'</entry>
  60. <entry>
  61. Type de contrôle de lecture (seulement si le contrôle de lecture
  62. est activé). Les valeurs disponibles sont&#160;: "md5" (meilleur mais
  63. plus lent), "crc32" (un peu moins sécurisé, mais plus rapide, c'est un
  64. meilleur choix), "adler32" (nouveau choix, plus rapide que
  65. crc32),"strlen" pour un test de longueur uniquement (le plus
  66. rapide).
  67. </entry>
  68. </row>
  69. <row>
  70. <entry><emphasis>hashed_directory_level</emphasis></entry>
  71. <entry><type>Integer</type></entry>
  72. <entry>0</entry>
  73. <entry>
  74. Niveau de structure du hash du répertoire&#160;: 0 signifie "pas de
  75. hashage de la structure du répertoire", 1 signifie "un niveau de
  76. répertoire", 2 signifie "deux niveaux"... Cette option peut accélérer
  77. le cache seulement lorsque vous avez plusieurs centaines de fichiers de
  78. cache. Seuls des tests de performance spécifiques peuvent vous aider à
  79. choisir la meilleure valeur pour vous. 1 ou 2, peut-être un bon
  80. départ.
  81. </entry>
  82. </row>
  83. <row>
  84. <entry><emphasis>hashed_directory_umask</emphasis></entry>
  85. <entry><type>Integer</type></entry>
  86. <entry>0700</entry>
  87. <entry>Umask pour l'arborescence</entry>
  88. </row>
  89. <row>
  90. <entry><emphasis>file_name_prefix</emphasis></entry>
  91. <entry><type>String</type></entry>
  92. <entry>'zend_cache'</entry>
  93. <entry>
  94. Préfixe pour les fichiers mis en cache&#160;; faîtes très attention
  95. avec cette option, en cas de valeur trop générique dans le dossier de
  96. cache (comme <filename>/tmp</filename>), ceci peut causer des désastres
  97. lors du nettoyage du cache.
  98. </entry>
  99. </row>
  100. <row>
  101. <entry><emphasis>cache_file_umask</emphasis></entry>
  102. <entry><type>Integer</type></entry>
  103. <entry>0700</entry>
  104. <entry>umask des fichiers de cache.</entry>
  105. </row>
  106. <row>
  107. <entry><emphasis>metatadatas_array_max_size</emphasis></entry>
  108. <entry><type>Integer</type></entry>
  109. <entry>100</entry>
  110. <entry>
  111. Taille maximale interne pour les tableaux de métadonnées (ne
  112. changez pas cette valeur à moins de bien savoir ce que vous
  113. faîtes).
  114. </entry>
  115. </row>
  116. </tbody>
  117. </tgroup>
  118. </table>
  119. </sect2>
  120. <sect2 id="zend.cache.backends.sqlite">
  121. <title>Zend_Cache_Backend_Sqlite</title>
  122. <para>
  123. Ce backend (étendu) stocke les enregistrements de cache dans une base de donnée
  124. SQLite.
  125. </para>
  126. <para>Les options disponibles sont&#160;:</para>
  127. <table id="zend.cache.backends.sqlite.table">
  128. <title>Options du backend Sqlite</title>
  129. <tgroup cols="4">
  130. <thead>
  131. <row>
  132. <entry>Option</entry>
  133. <entry>Type de données</entry>
  134. <entry>Valeur par défaut</entry>
  135. <entry>Description</entry>
  136. </row>
  137. </thead>
  138. <tbody>
  139. <row>
  140. <entry><emphasis>cache_db_complete_path (obligatoire)</emphasis></entry>
  141. <entry><type>String</type></entry>
  142. <entry><constant>NULL</constant></entry>
  143. <entry>
  144. Le chemin complet (nom du fichier inclus) de la base de donnée
  145. SQLite
  146. </entry>
  147. </row>
  148. <row>
  149. <entry><emphasis>automatic_vacuum_factor</emphasis></entry>
  150. <entry><type>Integer</type></entry>
  151. <entry>10</entry>
  152. <entry>
  153. Désactive / Active le processus de vidange automatique. Celui-ci
  154. défragmente le fichier de base de données (et diminue sa taille) quand
  155. <methodname>clean()</methodname> ou <methodname>delete()</methodname>
  156. est appelé&#160;: 0 pour une vidange automatique&#160;; 1
  157. pour une vidange systématique (quand <methodname>clean()</methodname>
  158. ou <methodname>delete()</methodname> est
  159. appelé)&#160;; x (entier) &gt; 1 pour une vidange automatique
  160. aléatoirement 1 fois sur x <methodname>clean()</methodname> ou
  161. <methodname>delete()</methodname>.
  162. </entry>
  163. </row>
  164. </tbody>
  165. </tgroup>
  166. </table>
  167. </sect2>
  168. <sect2 id="zend.cache.backends.memcached">
  169. <title>Zend_Cache_Backend_Memcached</title>
  170. <para>
  171. Ce backend (étendu) stocke les enregistrements de cache dans un serveur memcached.
  172. <ulink url="http://www.danga.com/memcached/">Memcached</ulink> est un système de cache
  173. en mémoire distribuée, de haute performance. Pour utiliser ce backend, vous devez avoir
  174. un démon memcached et l'extension
  175. <ulink url="http://pecl.php.net/package/memcache"><acronym>PECL</acronym>
  176. memcache</ulink>.
  177. </para>
  178. <para>
  179. Attention : avec ce backend, les balises ("tags") ne sont pas supportées pour le
  180. moment comme l'argument "doNotTestCacheValidity=true".
  181. </para>
  182. <para>Les options disponibles sont&#160;:</para>
  183. <table id="zend.cache.backends.memcached.table">
  184. <title>Options du backend Memcached</title>
  185. <tgroup cols="4">
  186. <thead>
  187. <row>
  188. <entry>Option</entry>
  189. <entry>Type de données</entry>
  190. <entry>Valeur par défaut</entry>
  191. <entry>Description</entry>
  192. </row>
  193. </thead>
  194. <tbody>
  195. <row>
  196. <entry><emphasis>servers</emphasis></entry>
  197. <entry><type>Array</type></entry>
  198. <entry>
  199. <command>array(array('host' => 'localhost', 'port' => 11211,
  200. 'persistent' => true, 'weight' => 1, 'timeout' => 5,
  201. 'retry_interval' => 15, 'status' => true,
  202. 'failure_callback' => '' ))</command>
  203. </entry>
  204. <entry>
  205. Un tableau de serveurs memcached&#160;; chaque serveur memcached est
  206. décrit par un tableau associatif&#160;: 'host' =&gt; (string)&#160;: le
  207. nom du serveur memcached, 'port' =&gt; (int)&#160;: le port du serveur
  208. memcached, 'persistent' =&gt; (bool)&#160;: utilisation ou pas des
  209. connexions persistantes pour ce serveur memcached, 'weight' =&gt;
  210. (int)&#160;: le poids du serveur memcached, 'timeout' =&gt;
  211. (int)&#160;: le time out du serveur memcached, 'retry_interval' =&gt;
  212. (int)&#160;: l'intervalle avant réexécution du serveur memcached,
  213. 'status' =&gt; (bool)&#160;: le statut du serveur memcached,
  214. 'failure_callback' =&gt; (callback)&#160;: le failure_callback d'échec
  215. du serveur memcached.
  216. </entry>
  217. </row>
  218. <row>
  219. <entry><emphasis>compression</emphasis></entry>
  220. <entry><type>Boolean</type></entry>
  221. <entry><constant>FALSE</constant></entry>
  222. <entry>
  223. <constant>TRUE</constant>, si vous voulez utiliser la compression à la
  224. volée
  225. </entry>
  226. </row>
  227. <row>
  228. <entry><emphasis>compatibility</emphasis></entry>
  229. <entry><type>Boolean</type></entry>
  230. <entry><constant>FALSE</constant></entry>
  231. <entry>
  232. <constant>TRUE</constant>, si vous voulez utiliser le mode de
  233. compatibilité avec les anciens serveurs&#160;/&#160;extensions memcache
  234. </entry>
  235. </row>
  236. </tbody>
  237. </tgroup>
  238. </table>
  239. </sect2>
  240. <sect2 id="zend.cache.backends.libmemcached">
  241. <title>Zend_Cache_Backend_Libmemcached</title>
  242. <para>
  243. This (extended) backend stores cache records into a memcached server.
  244. <ulink url="http://www.danga.com/memcached/">memcached</ulink>is a high-performance,
  245. distributed memory object caching system. To use this backend, you need a memcached daemon
  246. and
  247. <ulink url="http://pecl.php.net/package/memcached">the memcached
  248. <acronym>PECL</acronym>extension</ulink>.
  249. </para>
  250. <para>
  251. Be careful : with this backend, "tags" are not supported for the moment as the
  252. "doNotTestCacheValidity=true" argument.
  253. </para>
  254. <para>Available options are :</para>
  255. <table id="zend.cache.backends.libmemcached.table">
  256. <title>Libmemcached Backend Options</title>
  257. <tgroup cols="4">
  258. <thead>
  259. <row>
  260. <entry>Option</entry>
  261. <entry>Data Type</entry>
  262. <entry>Default Value</entry>
  263. <entry>Description</entry>
  264. </row>
  265. </thead>
  266. <tbody>
  267. <row>
  268. <entry><emphasis>servers</emphasis></entry>
  269. <entry>
  270. <type>Array</type>
  271. </entry>
  272. <entry>
  273. <command>array(array('host' =&gt; 'localhost', 'port' =&gt; 11211,
  274. 'weight' =&gt; 1))</command>
  275. </entry>
  276. <entry>
  277. An array of memcached servers ; each memcached server is described
  278. by an associative array: 'host' =&gt; (string) : the name of the memcached
  279. server, 'port' =&gt; (int) : the port of the memcached server, 'weight'
  280. =&gt; (int) :the weight of the memcached server
  281. </entry>
  282. </row>
  283. <row>
  284. <entry><emphasis>client</emphasis></entry>
  285. <entry>
  286. <type>Array</type>
  287. </entry>
  288. <entry>
  289. <command>array( Memcached::OPT_DISTRIBUTION =&gt;
  290. Memcached::DISTRIBUTION_CONSISTENT, Memcached::OPT_HASH =&gt;
  291. Memcached::HASH_MD5, Memcached::OPT_LIBKETAMA_COMPATIBLE =&gt; true
  292. )</command>
  293. </entry>
  294. <entry>
  295. An associative array of memcached client options ; The array key can
  296. be the name of the memcached option constant (without 'OPT_') or the
  297. integer value of it. See
  298. <ulink url="http://php.net/manual/memcached.constants.php">Memcached
  299. constants on
  300. <acronym>PHP</acronym>manual</ulink>
  301. </entry>
  302. </row>
  303. </tbody>
  304. </tgroup>
  305. </table>
  306. </sect2>
  307. <sect2 id="zend.cache.backends.apc">
  308. <title>Zend_Cache_Backend_Apc</title>
  309. <para>
  310. Ce backend (étendu) stocke les enregistrements de cache en mémoire partagée grâce
  311. à l'extension <ulink url="http://pecl.php.net/package/APC">APC</ulink>
  312. (Alternative <acronym>PHP</acronym> Cache) qui est requise pour utiliser ce backend.
  313. </para>
  314. <para>
  315. Attention: avec ce backend, les balises ("tags") ne sont pas supportées pour le
  316. moment comme l'argument "doNotTestCacheValidity=true".
  317. </para>
  318. <para>Il n'y a pas d'options pour ce backend.</para>
  319. </sect2>
  320. <sect2 id="zend.cache.backends.xcache">
  321. <title>Zend_Cache_Backend_Xcache</title>
  322. <para>
  323. Ce backend stocke ces enregistrements de cache dans la mémoire partagée à travers
  324. l'extension <ulink url="http://xcache.lighttpd.net/">XCache</ulink>(qui est bien sûr
  325. nécessaire pour utiliser ce backend).
  326. </para>
  327. <para>
  328. Attention : avec ce backend, les balises ("tags") ne sont pas supportées pour le
  329. moment comme l'argument "doNotTestCacheValidity=true".
  330. </para>
  331. <para>Les options disponibles sont&#160;:</para>
  332. <table id="zend.cache.backends.xcache.table">
  333. <title>Options du backend Xcache</title>
  334. <tgroup cols="4">
  335. <thead>
  336. <row>
  337. <entry>Option</entry>
  338. <entry>Type de données</entry>
  339. <entry>Valeur par défaut</entry>
  340. <entry>Description</entry>
  341. </row>
  342. </thead>
  343. <tbody>
  344. <row>
  345. <entry><emphasis>user</emphasis></entry>
  346. <entry><type>String</type></entry>
  347. <entry><constant>NULL</constant></entry>
  348. <entry>
  349. <filename>xcache.admin.user</filename>, nécessaire pour la
  350. méthode <methodname>clean()</methodname>.
  351. </entry>
  352. </row>
  353. <row>
  354. <entry><emphasis>password</emphasis></entry>
  355. <entry><type>String</type></entry>
  356. <entry><constant>NULL</constant></entry>
  357. <entry>
  358. <filename>xcache.admin.pass</filename> (en texte clair non
  359. <acronym>MD5</acronym>), nécessaire pour la méthode
  360. <methodname>clean()</methodname>.
  361. </entry>
  362. </row>
  363. </tbody>
  364. </tgroup>
  365. </table>
  366. </sect2>
  367. <sect2 id="zend.cache.backends.platform">
  368. <title>Zend_Cache_Backend_ZendPlatform</title>
  369. <para>
  370. Ce backend utilise l'<acronym>API</acronym> de cache de contenu de la
  371. <ulink url="http://www.zend.com/fr/products/platform">Zend Platform</ulink>.
  372. Naturellement, pour utiliser ce backend, vous devez avoir installé une Zend Platorm.
  373. </para>
  374. <para>
  375. Ce backend supporte les balises ("tags") mais ne supporte pas le mode de
  376. nettoyage <constant>CLEANING_MODE_NOT_MATCHING_TAG</constant>.
  377. </para>
  378. <para>
  379. Spécifiez ce backend en utilisant un séparateur de mot - "-", ".", " " ou "_" -
  380. entre les mots "Zend" et "Platform" quand vous utilisez la méthode
  381. <methodname>Zend_Cache::factory()</methodname>&#160;:
  382. </para>
  383. <programlisting language="php"><![CDATA[
  384. $cache = Zend_Cache::factory('Core', 'Zend Platform');
  385. ]]></programlisting>
  386. <para>Il n'y a pas d'options pour ce backend.</para>
  387. </sect2>
  388. <sect2 id="zend.cache.backends.twolevels">
  389. <title>Zend_Cache_Backend_TwoLevels</title>
  390. <para>
  391. Ce backend (étendu) est un hybride. Il stocke les enregistrements de cache dans
  392. deux autres backends&#160;: un rapide (mais limité) comme Apc, Memcache... et un plus
  393. "lent" comme File, Sqlite...
  394. </para>
  395. <para>
  396. Ce backend utilise le paramètre priorité (fourni au niveau du frontend au moment
  397. d'un enregistrement) et l'espace restant dans le backend rapide pour optimiser
  398. l'utilisation de ces deux backends.
  399. </para>
  400. <para>
  401. Spécifiez ce backend avec un séparateur de mots - "-", ".", " ", ou "_" - entre les
  402. mots "Two" et "Levels" quand vous utilisez la méthode
  403. <methodname>Zend_Cache::factory()</methodname>&#160;:
  404. </para>
  405. <programlisting language="php"><![CDATA[
  406. $cache = Zend_Cache::factory('Core', 'Two Levels');
  407. ]]></programlisting>
  408. <para>Les options disponibles sont :</para>
  409. <table id="zend.cache.backends.twolevels.table">
  410. <title>Options du backend TwoLevels</title>
  411. <tgroup cols="4">
  412. <thead>
  413. <row>
  414. <entry>Option</entry>
  415. <entry>Type de données</entry>
  416. <entry>Valeur par défaut</entry>
  417. <entry>Description</entry>
  418. </row>
  419. </thead>
  420. <tbody>
  421. <row>
  422. <entry><emphasis>slow_backend</emphasis></entry>
  423. <entry><type>String</type></entry>
  424. <entry>File</entry>
  425. <entry>le nom du backend "lent"</entry>
  426. </row>
  427. <row>
  428. <entry><emphasis>fast_backend</emphasis></entry>
  429. <entry><type>String</type></entry>
  430. <entry>Apc</entry>
  431. <entry>le nom du backend "rapide"</entry>
  432. </row>
  433. <row>
  434. <entry><emphasis>slow_backend_options</emphasis></entry>
  435. <entry><type>Array</type></entry>
  436. <entry><methodname>array()</methodname></entry>
  437. <entry>les options du backend "lent"</entry>
  438. </row>
  439. <row>
  440. <entry><emphasis>fast_backend_options</emphasis></entry>
  441. <entry><type>Array</type></entry>
  442. <entry><methodname>array()</methodname></entry>
  443. <entry>les options du backend "rapide"</entry>
  444. </row>
  445. <row>
  446. <entry><emphasis>slow_backend_custom_naming</emphasis></entry>
  447. <entry><type>Boolean</type></entry>
  448. <entry><constant>FALSE</constant></entry>
  449. <entry>
  450. si <constant>TRUE</constant>, l'argument "slow_backend" est
  451. utilisé en tant que nom complet de classe&#160;; si
  452. <constant>FALSE</constant>, l'argument frontend est utilisé concaténé à
  453. "<classname>Zend_Cache_Backend_&lt;...&gt;</classname>"
  454. </entry>
  455. </row>
  456. <row>
  457. <entry><emphasis>fast_backend_custom_naming</emphasis></entry>
  458. <entry><type>Boolean</type></entry>
  459. <entry><constant>FALSE</constant></entry>
  460. <entry>
  461. si <constant>TRUE</constant>, l'argument "fast_backend" est
  462. utilisé en tant que nom complet de classe&#160;; si
  463. <constant>FALSE</constant>, l'argument frontend est utilisé concaténé à
  464. "<classname>Zend_Cache_Backend_&lt;...&gt;</classname>"
  465. </entry>
  466. </row>
  467. <row>
  468. <entry><emphasis>slow_backend_autoload</emphasis></entry>
  469. <entry><type>Boolean</type></entry>
  470. <entry><constant>FALSE</constant></entry>
  471. <entry>
  472. si <constant>TRUE</constant>, il n'y aura pas de require_once pour le
  473. "slow_backend" (utile seulement pour les backends
  474. personnalisés)
  475. </entry>
  476. </row>
  477. <row>
  478. <entry><emphasis>fast_backend_autoload</emphasis></entry>
  479. <entry><type>Boolean</type></entry>
  480. <entry><constant>FALSE</constant></entry>
  481. <entry>
  482. si <constant>TRUE</constant>, il n'y aura pas de require_once pour le
  483. "fast_backend" (utile seulement pour les backends
  484. personnalisés)
  485. </entry>
  486. </row>
  487. <row>
  488. <entry><emphasis>auto_refresh_fast_cache</emphasis></entry>
  489. <entry><type>Boolean</type></entry>
  490. <entry><constant>TRUE</constant></entry>
  491. <entry>
  492. si <constant>TRUE</constant>, rafraîchissement automatique du cache
  493. rapide quand un enregistrement est appelé
  494. </entry>
  495. </row>
  496. <row>
  497. <entry><emphasis>stats_update_factor</emphasis></entry>
  498. <entry><type>Integer</type></entry>
  499. <entry>10</entry>
  500. <entry>
  501. désactive&#160;/&#160;personnalise le calcul du pourcentage de
  502. remplissage du backend rapide (lors d'une sauvegarde d'un enregistrement
  503. dans le cache, le calcul du remplissage est effectué aléatoirement
  504. 1 fois sur x écritures de cache)
  505. </entry>
  506. </row>
  507. </tbody>
  508. </tgroup>
  509. </table>
  510. </sect2>
  511. <sect2 id="zend.cache.backends.zendserver">
  512. <title> Zend_Cache_Backend_ZendServer_Disk et Zend_Cache_Backend_ZendServer_ShMem </title>
  513. <para>
  514. Ces backends utilisent les fonctionnalités de mise en cache de
  515. <ulink url="http://www.zend.com/en/products/server/downloads-all?zfs=zf_download">Zend
  516. Server</ulink>pour stocker les données.
  517. </para>
  518. <para>
  519. Attention : avec ces backends ne supportent pas les balises ("tags") pour le
  520. moment de même que l'argument "doNotTestCacheValidity=true".
  521. </para>
  522. <para>
  523. Ces backends fonctionnent seulement dans l'environnement de Zend Server pour les
  524. pages requêtées à travers <acronym>HTTP</acronym> ou <acronym>HTTPS</acronym> et ne
  525. fonctionnent pas pour les scripts exécutés en ligne de commande.
  526. </para>
  527. <para>
  528. Spécifiez ce backend en utilisant le paramètre <emphasis>customBackendNaming</emphasis>
  529. à <constant>TRUE</constant> quand vous utilisez la méthode
  530. <methodname>Zend_Cache::factory()</methodname>&#160;:
  531. </para>
  532. <programlisting language="php"><![CDATA[
  533. $cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_ZendServer_Disk',
  534. $frontendOptions, $backendOptions, false, true);
  535. ]]></programlisting>
  536. <para>Il n'y a pas d'options pour ce backend.</para>
  537. </sect2>
  538. <sect2 id="zend.cache.backends.static">
  539. <title>Zend_Cache_Backend_Static</title>
  540. <para>
  541. This backend works in concert with <classname>Zend_Cache_Frontend_Capture</classname>
  542. (the two must be used together) to save the output from requests as static files. This
  543. means the static files are served directly on subsequent requests without any
  544. involvement of <acronym>PHP</acronym> or Zend Framework at all.
  545. </para>
  546. <note>
  547. <para>
  548. <classname>Zend_Cache_Frontend_Capture</classname> operates
  549. by registering a callback function to be called
  550. when the output buffering it uses is cleaned. In order for this to operate
  551. correctly, it must be the final output buffer in the request. To guarantee
  552. this, the output buffering used by the Dispatcher <emphasis>must</emphasis> be
  553. disabled by calling <classname>Zend_Controller_Front</classname>'s
  554. <methodname>setParam()</methodname> method, for example,
  555. <command>$front->setParam('disableOutputBuffering', true);</command> or adding
  556. "resources.frontcontroller.params.disableOutputBuffering = true"
  557. to your bootstrap configuration file (assumed <acronym>INI</acronym>) if using
  558. <classname>Zend_Application</classname>.
  559. </para>
  560. </note>
  561. <para>
  562. The benefits of this cache include a large throughput increase since
  563. all subsequent requests return the static file and don't need any
  564. dynamic processing. Of course this also has some disadvantages. The
  565. only way to retry the dynamic request is to purge the cached file
  566. from elsewhere in the application (or via a cronjob if timed). It
  567. is also restricted to single-server applications where only one
  568. filesystem is used. Nevertheless, it can be a powerful means of
  569. getting more performance without incurring the cost of a proxy on
  570. single machines.
  571. </para>
  572. <para>
  573. Before describing its options, you should note this needs some
  574. changes to the default <filename>.htaccess</filename> file in order for requests to be
  575. directed to the static files if they exist. Here's an example of
  576. a simple application caching some content, including two specific
  577. feeds which need additional treatment to serve a correct
  578. Content-Type header:
  579. </para>
  580. <programlisting language="text"><![CDATA[
  581. AddType application/rss+xml .xml
  582. AddType application/atom+xml .xml
  583. RewriteEngine On
  584. RewriteCond %{REQUEST_URI} feed/rss$
  585. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  586. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/rss+xml]
  587. RewriteCond %{REQUEST_URI} feed/atom$
  588. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  589. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/atom+xml]
  590. RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
  591. RewriteRule ^/*$ cached/index.html [L]
  592. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.(html|xml|json|opml|svg) -f
  593. RewriteRule .* cached/%{REQUEST_URI}.%1 [L]
  594. RewriteCond %{REQUEST_FILENAME} -s [OR]
  595. RewriteCond %{REQUEST_FILENAME} -l [OR]
  596. RewriteCond %{REQUEST_FILENAME} -d
  597. RewriteRule ^.*$ - [NC,L]
  598. RewriteRule ^.*$ index.php [NC,L]
  599. ]]></programlisting>
  600. <para>
  601. The above assumes static files are cached to the directory
  602. <filename>./public/cached</filename>. We'll cover the option setting this location,
  603. "public_dir", below.
  604. </para>
  605. <para>
  606. Due to the nature of static file caching, the backend class offers two additional
  607. methods: <methodname>remove()</methodname> and
  608. <methodname>removeRecursively()</methodname>. Both accept a request
  609. <acronym>URI</acronym>, which when mapped to the "public_dir" where static files are
  610. cached, and has a pre-stored extension appended, provides the name of either a static
  611. file to delete, or a directory path to delete recursively. Due to the
  612. restraints of <classname>Zend_Cache_Backend_Interface</classname>, all
  613. other methods such as <methodname>save()</methodname> accept an ID which
  614. is calculated by applying <methodname>bin2hex()</methodname> to a request
  615. <acronym>URI</acronym>.
  616. </para>
  617. <para>
  618. Given the level at which static caching operates, static file caching is addressed for
  619. simpler use with the <classname>Zend_Controller_Action_Helper_Cache</classname> action
  620. helper. This helper assists in setting which actions of a controller to cache, with what
  621. tags, and with which extension. It also offers methods for purging the cache by request
  622. <acronym>URI</acronym> or tag. Static file caching is also assisted by
  623. <classname>Zend_Cache_Manager</classname> which includes pre-configured configuration
  624. templates for a static cache (as <constant>Zend_Cache_Manager::PAGECACHE</constant> or
  625. "page"). The defaults therein can be configured as needed to set up a "public_dir"
  626. location for caching, etc.
  627. </para>
  628. <note>
  629. <para>
  630. It should be noted that the static cache actually uses a secondary cache to store
  631. tags (obviously we can't store them elsewhere since a static cache does not invoke
  632. <acronym>PHP</acronym> if working correctly). This is just a standard Core cache,
  633. and should use a persistent backend such as File or TwoLevels (to take advantage of
  634. memory storage without sacrificing permanent persistance). The backend includes the
  635. option "tag_cache" to set this up (it is obligatory), or the
  636. <methodname>setInnerCache()</methodname> method.
  637. </para>
  638. </note>
  639. <table id="zend.cache.backends.static.table">
  640. <title>Static Backend Options</title>
  641. <tgroup cols="4">
  642. <thead>
  643. <row>
  644. <entry>Option</entry>
  645. <entry>Data Type</entry>
  646. <entry>Default Value</entry>
  647. <entry>Description</entry>
  648. </row>
  649. </thead>
  650. <tbody>
  651. <row>
  652. <entry><emphasis>public_dir</emphasis></entry>
  653. <entry><type>String</type></entry>
  654. <entry><constant>NULL</constant></entry>
  655. <entry>
  656. Directory where to store static files. This must exist
  657. in your public directory.
  658. </entry>
  659. </row>
  660. <row>
  661. <entry><emphasis>file_locking</emphasis></entry>
  662. <entry><type>Boolean</type></entry>
  663. <entry><constant>TRUE</constant></entry>
  664. <entry>
  665. Enable or disable file_locking : Can avoid cache corruption under
  666. bad circumstances but it doesn't help on multithread webservers
  667. or on <acronym>NFS</acronym> filesystems...
  668. </entry>
  669. </row>
  670. <row>
  671. <entry><emphasis>read_control</emphasis></entry>
  672. <entry><type>Boolean</type></entry>
  673. <entry><constant>TRUE</constant></entry>
  674. <entry>
  675. Enable / disable read control : if enabled, a control key is
  676. embedded in the cache file and this key is compared with the
  677. one calculated after the reading.
  678. </entry>
  679. </row>
  680. <row>
  681. <entry><emphasis>read_control_type</emphasis></entry>
  682. <entry><type>String</type></entry>
  683. <entry>'crc32'</entry>
  684. <entry>
  685. Type of read control (only if read control is enabled). Available values
  686. are : 'md5' (best but slowest), 'crc32' (lightly less safe but faster,
  687. better choice), 'adler32' (new choice, faster than crc32),
  688. 'strlen' for a length only test (fastest).
  689. </entry>
  690. </row>
  691. <row>
  692. <entry><emphasis>cache_file_umask</emphasis></entry>
  693. <entry><type>Integer</type></entry>
  694. <entry>0700</entry>
  695. <entry>umask for cached files.</entry>
  696. </row>
  697. <row>
  698. <entry><emphasis>cache_directory_umask</emphasis></entry>
  699. <entry><type>Integer</type></entry>
  700. <entry>0700</entry>
  701. <entry>Umask for directories created within public_dir.</entry>
  702. </row>
  703. <row>
  704. <entry><emphasis>file_extension</emphasis></entry>
  705. <entry><type>String</type></entry>
  706. <entry>'<filename>.html</filename>'</entry>
  707. <entry>
  708. Default file extension for static files created. This can be
  709. configured on the fly, see
  710. <methodname>Zend_Cache_Backend_Static::save()</methodname> though
  711. generally it's recommended to rely on
  712. <classname>Zend_Controller_Action_Helper_Cache</classname> when
  713. doing so since it's simpler that way than messing with
  714. arrays or serialization manually.
  715. </entry>
  716. </row>
  717. <row>
  718. <entry><emphasis>index_filename</emphasis></entry>
  719. <entry><type>String</type></entry>
  720. <entry>'index'</entry>
  721. <entry>
  722. If a request <acronym>URI</acronym> does not contain sufficient
  723. information to construct a static file (usually this means an index
  724. call, e.g. <acronym>URI</acronym> of '/'), the index_filename is used
  725. instead. So '' or '/' would map to '<filename>index.html</filename>'
  726. (assuming the default file_extension is '<filename>.html</filename>').
  727. </entry>
  728. </row>
  729. <row>
  730. <entry><emphasis>tag_cache</emphasis></entry>
  731. <entry><type>Object</type></entry>
  732. <entry><constant>NULL</constant></entry>
  733. <entry>
  734. Used to set an 'inner' cache utilised to store tags
  735. and file extensions associated with static files. This
  736. <emphasis>must</emphasis> be set or the static cache cannot be tracked
  737. and managed.
  738. </entry>
  739. </row>
  740. <row>
  741. <entry><emphasis>disable_caching</emphasis></entry>
  742. <entry><type>Boolean</type></entry>
  743. <entry><constant>FALSE</constant></entry>
  744. <entry>
  745. If set to <constant>TRUE</constant>, static files will not be cached.
  746. This will force all requests to be dynamic even if marked
  747. to be cached in Controllers. Useful for debugging.
  748. </entry>
  749. </row>
  750. </tbody>
  751. </tgroup>
  752. </table>
  753. </sect2>
  754. </sect1>