Zend_Cache-Backends.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- EN-Revision: 24434 -->
  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>[system temp dir]</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>0600</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. Ce backend (étendu) stocke les enregistrements de cache dans un serveur memcached.
  244. <ulink url="http://www.danga.com/memcached/">memcached</ulink> est un système distribué
  245. de cache d'objet en mémoire de haute performance. Pour utiliser ce backend, vous avez
  246. besoin d'un démon memcached et de l'extension
  247. <ulink url="http://pecl.php.net/package/memcached"><acronym>PECL</acronym>
  248. memcached</ulink>.
  249. </para>
  250. <para>
  251. Attention: avec ce backend, les balises ("tags") ne sont pas supportées pour le
  252. moment comme l'argument "doNotTestCacheValidity=true".
  253. </para>
  254. <para>Les options disponibles sont&#160;:</para>
  255. <table id="zend.cache.backends.libmemcached.table">
  256. <title>Options du backend Libmemcached</title>
  257. <tgroup cols="4">
  258. <thead>
  259. <row>
  260. <entry>Option</entry>
  261. <entry>Type de données</entry>
  262. <entry>Valeur par défaut</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. Un tableau de serveurs memcached&#160;; chaque serveur memcached est
  278. décrit par un tableau associatif&#160;: 'host' =&gt; (string)&#160;: le
  279. nom du serveur memcached, 'port' =&gt; (int)&#160;: le port du serveur
  280. memcached, 'weight' =&gt; (int)&#160;: le poids du serveur memcached.
  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. Un tableau associatif des options de client memcached. Les clés du
  296. tableau peuvent le nom de la constante d'option memcache (sans le OPT_)
  297. ou la valeur de type entier de celui-ci. Voir aussi
  298. <ulink url="http://php.net/manual/memcached.constants.php">les
  299. constantes Memcached dans le manuel <acronym>PHP</acronym></ulink>
  300. </entry>
  301. </row>
  302. </tbody>
  303. </tgroup>
  304. </table>
  305. </sect2>
  306. <sect2 id="zend.cache.backends.apc">
  307. <title>Zend_Cache_Backend_Apc</title>
  308. <para>
  309. Ce backend (étendu) stocke les enregistrements de cache en mémoire partagée grâce
  310. à l'extension <ulink url="http://pecl.php.net/package/APC">APC</ulink>
  311. (Alternative <acronym>PHP</acronym> Cache) qui est requise pour utiliser ce backend.
  312. </para>
  313. <para>
  314. Attention: avec ce backend, les balises ("tags") ne sont pas supportées pour le
  315. moment comme l'argument "doNotTestCacheValidity=true".
  316. </para>
  317. <para>Il n'y a pas d'options pour ce backend.</para>
  318. </sect2>
  319. <sect2 id="zend.cache.backends.xcache">
  320. <title>Zend_Cache_Backend_Xcache</title>
  321. <para>
  322. Ce backend stocke ces enregistrements de cache dans la mémoire partagée à travers
  323. l'extension <ulink url="http://xcache.lighttpd.net/">XCache</ulink>(qui est bien sûr
  324. nécessaire pour utiliser ce backend).
  325. </para>
  326. <para>
  327. Attention : avec ce backend, les balises ("tags") ne sont pas supportées pour le
  328. moment comme l'argument "doNotTestCacheValidity=true".
  329. </para>
  330. <para>Les options disponibles sont&#160;:</para>
  331. <table id="zend.cache.backends.xcache.table">
  332. <title>Options du backend Xcache</title>
  333. <tgroup cols="4">
  334. <thead>
  335. <row>
  336. <entry>Option</entry>
  337. <entry>Type de données</entry>
  338. <entry>Valeur par défaut</entry>
  339. <entry>Description</entry>
  340. </row>
  341. </thead>
  342. <tbody>
  343. <row>
  344. <entry><emphasis>user</emphasis></entry>
  345. <entry><type>String</type></entry>
  346. <entry><constant>NULL</constant></entry>
  347. <entry>
  348. <filename>xcache.admin.user</filename>, nécessaire pour la
  349. méthode <methodname>clean()</methodname>.
  350. </entry>
  351. </row>
  352. <row>
  353. <entry><emphasis>password</emphasis></entry>
  354. <entry><type>String</type></entry>
  355. <entry><constant>NULL</constant></entry>
  356. <entry>
  357. <filename>xcache.admin.pass</filename> (en texte clair non
  358. <acronym>MD5</acronym>), nécessaire pour la méthode
  359. <methodname>clean()</methodname>.
  360. </entry>
  361. </row>
  362. </tbody>
  363. </tgroup>
  364. </table>
  365. </sect2>
  366. <sect2 id="zend.cache.backends.platform">
  367. <title>Zend_Cache_Backend_ZendPlatform</title>
  368. <para>
  369. Ce backend utilise l'<acronym>API</acronym> de cache de contenu de la
  370. <ulink url="http://www.zend.com/fr/products/platform">Zend Platform</ulink>.
  371. Naturellement, pour utiliser ce backend, vous devez avoir installé une Zend Platorm.
  372. </para>
  373. <para>
  374. Ce backend supporte les balises ("tags") mais ne supporte pas le mode de
  375. nettoyage <constant>CLEANING_MODE_NOT_MATCHING_TAG</constant>.
  376. </para>
  377. <para>
  378. Spécifiez ce backend en utilisant un séparateur de mot - "-", ".", " " ou "_" -
  379. entre les mots "Zend" et "Platform" quand vous utilisez la méthode
  380. <methodname>Zend_Cache::factory()</methodname>&#160;:
  381. </para>
  382. <programlisting language="php"><![CDATA[
  383. $cache = Zend_Cache::factory('Core', 'Zend Platform');
  384. ]]></programlisting>
  385. <para>Il n'y a pas d'options pour ce backend.</para>
  386. </sect2>
  387. <sect2 id="zend.cache.backends.twolevels">
  388. <title>Zend_Cache_Backend_TwoLevels</title>
  389. <para>
  390. Ce backend (étendu) est un hybride. Il stocke les enregistrements de cache dans
  391. deux autres backends&#160;: un rapide (mais limité) comme Apc, Memcache... et un plus
  392. "lent" comme File, Sqlite...
  393. </para>
  394. <para>
  395. Ce backend utilise le paramètre priorité (fourni au niveau du frontend au moment
  396. d'un enregistrement) et l'espace restant dans le backend rapide pour optimiser
  397. l'utilisation de ces deux backends.
  398. </para>
  399. <para>
  400. Spécifiez ce backend avec un séparateur de mots - "-", ".", " ", ou "_" - entre les
  401. mots "Two" et "Levels" quand vous utilisez la méthode
  402. <methodname>Zend_Cache::factory()</methodname>&#160;:
  403. </para>
  404. <programlisting language="php"><![CDATA[
  405. $cache = Zend_Cache::factory('Core', 'Two Levels');
  406. ]]></programlisting>
  407. <para>Les options disponibles sont :</para>
  408. <table id="zend.cache.backends.twolevels.table">
  409. <title>Options du backend TwoLevels</title>
  410. <tgroup cols="4">
  411. <thead>
  412. <row>
  413. <entry>Option</entry>
  414. <entry>Type de données</entry>
  415. <entry>Valeur par défaut</entry>
  416. <entry>Description</entry>
  417. </row>
  418. </thead>
  419. <tbody>
  420. <row>
  421. <entry><emphasis>slow_backend</emphasis></entry>
  422. <entry><type>String</type></entry>
  423. <entry>File</entry>
  424. <entry>le nom du backend "lent"</entry>
  425. </row>
  426. <row>
  427. <entry><emphasis>fast_backend</emphasis></entry>
  428. <entry><type>String</type></entry>
  429. <entry>Apc</entry>
  430. <entry>le nom du backend "rapide"</entry>
  431. </row>
  432. <row>
  433. <entry><emphasis>slow_backend_options</emphasis></entry>
  434. <entry><type>Array</type></entry>
  435. <entry><methodname>array()</methodname></entry>
  436. <entry>les options du backend "lent"</entry>
  437. </row>
  438. <row>
  439. <entry><emphasis>fast_backend_options</emphasis></entry>
  440. <entry><type>Array</type></entry>
  441. <entry><methodname>array()</methodname></entry>
  442. <entry>les options du backend "rapide"</entry>
  443. </row>
  444. <row>
  445. <entry><emphasis>slow_backend_custom_naming</emphasis></entry>
  446. <entry><type>Boolean</type></entry>
  447. <entry><constant>FALSE</constant></entry>
  448. <entry>
  449. si <constant>TRUE</constant>, l'argument "slow_backend" est
  450. utilisé en tant que nom complet de classe&#160;; si
  451. <constant>FALSE</constant>, l'argument frontend est utilisé concaténé à
  452. "<classname>Zend_Cache_Backend_&lt;...&gt;</classname>"
  453. </entry>
  454. </row>
  455. <row>
  456. <entry><emphasis>fast_backend_custom_naming</emphasis></entry>
  457. <entry><type>Boolean</type></entry>
  458. <entry><constant>FALSE</constant></entry>
  459. <entry>
  460. si <constant>TRUE</constant>, l'argument "fast_backend" est
  461. utilisé en tant que nom complet de classe&#160;; si
  462. <constant>FALSE</constant>, l'argument frontend est utilisé concaténé à
  463. "<classname>Zend_Cache_Backend_&lt;...&gt;</classname>"
  464. </entry>
  465. </row>
  466. <row>
  467. <entry><emphasis>slow_backend_autoload</emphasis></entry>
  468. <entry><type>Boolean</type></entry>
  469. <entry><constant>FALSE</constant></entry>
  470. <entry>
  471. si <constant>TRUE</constant>, il n'y aura pas de require_once pour le
  472. "slow_backend" (utile seulement pour les backends
  473. personnalisés)
  474. </entry>
  475. </row>
  476. <row>
  477. <entry><emphasis>fast_backend_autoload</emphasis></entry>
  478. <entry><type>Boolean</type></entry>
  479. <entry><constant>FALSE</constant></entry>
  480. <entry>
  481. si <constant>TRUE</constant>, il n'y aura pas de require_once pour le
  482. "fast_backend" (utile seulement pour les backends
  483. personnalisés)
  484. </entry>
  485. </row>
  486. <row>
  487. <entry><emphasis>auto_refresh_fast_cache</emphasis></entry>
  488. <entry><type>Boolean</type></entry>
  489. <entry><constant>TRUE</constant></entry>
  490. <entry>
  491. si <constant>TRUE</constant>, rafraîchissement automatique du cache
  492. rapide quand un enregistrement est appelé
  493. </entry>
  494. </row>
  495. <row>
  496. <entry><emphasis>stats_update_factor</emphasis></entry>
  497. <entry><type>Integer</type></entry>
  498. <entry>10</entry>
  499. <entry>
  500. désactive&#160;/&#160;personnalise le calcul du pourcentage de
  501. remplissage du backend rapide (lors d'une sauvegarde d'un enregistrement
  502. dans le cache, le calcul du remplissage est effectué aléatoirement
  503. 1 fois sur x écritures de cache)
  504. </entry>
  505. </row>
  506. </tbody>
  507. </tgroup>
  508. </table>
  509. </sect2>
  510. <sect2 id="zend.cache.backends.zendserver">
  511. <title> Zend_Cache_Backend_ZendServer_Disk et Zend_Cache_Backend_ZendServer_ShMem </title>
  512. <para>
  513. Ces backends utilisent les fonctionnalités de mise en cache de
  514. <ulink url="http://www.zend.com/en/products/server/downloads-all?zfs=zf_download">Zend
  515. Server</ulink>pour stocker les données.
  516. </para>
  517. <para>
  518. Attention : avec ces backends ne supportent pas les balises ("tags") pour le
  519. moment de même que l'argument "doNotTestCacheValidity=true".
  520. </para>
  521. <para>
  522. Ces backends fonctionnent seulement dans l'environnement de Zend Server pour les
  523. pages requêtées à travers <acronym>HTTP</acronym> ou <acronym>HTTPS</acronym> et ne
  524. fonctionnent pas pour les scripts exécutés en ligne de commande.
  525. </para>
  526. <para>
  527. Spécifiez ce backend en utilisant le paramètre <emphasis>customBackendNaming</emphasis>
  528. à <constant>TRUE</constant> quand vous utilisez la méthode
  529. <methodname>Zend_Cache::factory()</methodname>&#160;:
  530. </para>
  531. <programlisting language="php"><![CDATA[
  532. $cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_ZendServer_Disk',
  533. $frontendOptions, $backendOptions, false, true);
  534. ]]></programlisting>
  535. <para>Il n'y a pas d'options pour ce backend.</para>
  536. </sect2>
  537. <sect2 id="zend.cache.backends.static">
  538. <title>Zend_Cache_Backend_Static</title>
  539. <para>
  540. This backend works in concert with <classname>Zend_Cache_Frontend_Capture</classname>
  541. (the two must be used together) to save the output from requests as static files. This
  542. means the static files are served directly on subsequent requests without any
  543. involvement of <acronym>PHP</acronym> or Zend Framework at all.
  544. </para>
  545. <note>
  546. <para>
  547. <classname>Zend_Cache_Frontend_Capture</classname> operates
  548. by registering a callback function to be called
  549. when the output buffering it uses is cleaned. In order for this to operate
  550. correctly, it must be the final output buffer in the request. To guarantee
  551. this, the output buffering used by the Dispatcher <emphasis>must</emphasis> be
  552. disabled by calling <classname>Zend_Controller_Front</classname>'s
  553. <methodname>setParam()</methodname> method, for example,
  554. <command>$front->setParam('disableOutputBuffering', true);</command> or adding
  555. "resources.frontcontroller.params.disableOutputBuffering = true"
  556. to your bootstrap configuration file (assumed <acronym>INI</acronym>) if using
  557. <classname>Zend_Application</classname>.
  558. </para>
  559. </note>
  560. <para>
  561. The benefits of this cache include a large throughput increase since
  562. all subsequent requests return the static file and don't need any
  563. dynamic processing. Of course this also has some disadvantages. The
  564. only way to retry the dynamic request is to purge the cached file
  565. from elsewhere in the application (or via a cronjob if timed). It
  566. is also restricted to single-server applications where only one
  567. filesystem is used. Nevertheless, it can be a powerful means of
  568. getting more performance without incurring the cost of a proxy on
  569. single machines.
  570. </para>
  571. <para>
  572. Before describing its options, you should note this needs some
  573. changes to the default <filename>.htaccess</filename> file in order for requests to be
  574. directed to the static files if they exist. Here's an example of
  575. a simple application caching some content, including two specific
  576. feeds which need additional treatment to serve a correct
  577. Content-Type header:
  578. </para>
  579. <programlisting language="text"><![CDATA[
  580. AddType application/rss+xml .xml
  581. AddType application/atom+xml .xml
  582. RewriteEngine On
  583. RewriteCond %{REQUEST_URI} feed/rss$
  584. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  585. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/rss+xml]
  586. RewriteCond %{REQUEST_URI} feed/atom$
  587. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.xml -f
  588. RewriteRule .* cached/%{REQUEST_URI}.xml [L,T=application/atom+xml]
  589. RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
  590. RewriteRule ^/*$ cached/index.html [L]
  591. RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}.(html|xml|json|opml|svg) -f
  592. RewriteRule .* cached/%{REQUEST_URI}.%1 [L]
  593. RewriteCond %{REQUEST_FILENAME} -s [OR]
  594. RewriteCond %{REQUEST_FILENAME} -l [OR]
  595. RewriteCond %{REQUEST_FILENAME} -d
  596. RewriteRule ^.*$ - [NC,L]
  597. RewriteRule ^.*$ index.php [NC,L]
  598. ]]></programlisting>
  599. <para>
  600. The above assumes static files are cached to the directory
  601. <filename>./public/cached</filename>. We'll cover the option setting this location,
  602. "public_dir", below.
  603. </para>
  604. <para>
  605. Due to the nature of static file caching, the backend class offers two additional
  606. methods: <methodname>remove()</methodname> and
  607. <methodname>removeRecursively()</methodname>. Both accept a request
  608. <acronym>URI</acronym>, which when mapped to the "public_dir" where static files are
  609. cached, and has a pre-stored extension appended, provides the name of either a static
  610. file to delete, or a directory path to delete recursively. Due to the
  611. restraints of <classname>Zend_Cache_Backend_Interface</classname>, all
  612. other methods such as <methodname>save()</methodname> accept an ID which
  613. is calculated by applying <methodname>bin2hex()</methodname> to a request
  614. <acronym>URI</acronym>.
  615. </para>
  616. <para>
  617. Given the level at which static caching operates, static file caching is addressed for
  618. simpler use with the <classname>Zend_Controller_Action_Helper_Cache</classname> action
  619. helper. This helper assists in setting which actions of a controller to cache, with what
  620. tags, and with which extension. It also offers methods for purging the cache by request
  621. <acronym>URI</acronym> or tag. Static file caching is also assisted by
  622. <classname>Zend_Cache_Manager</classname> which includes pre-configured configuration
  623. templates for a static cache (as <constant>Zend_Cache_Manager::PAGECACHE</constant> or
  624. "page"). The defaults therein can be configured as needed to set up a "public_dir"
  625. location for caching, etc.
  626. </para>
  627. <note>
  628. <para>
  629. It should be noted that the static cache actually uses a secondary cache to store
  630. tags (obviously we can't store them elsewhere since a static cache does not invoke
  631. <acronym>PHP</acronym> if working correctly). This is just a standard Core cache,
  632. and should use a persistent backend such as File or TwoLevels (to take advantage of
  633. memory storage without sacrificing permanent persistance). The backend includes the
  634. option "tag_cache" to set this up (it is obligatory), or the
  635. <methodname>setInnerCache()</methodname> method.
  636. </para>
  637. </note>
  638. <table id="zend.cache.backends.static.table">
  639. <title>Static Backend Options</title>
  640. <tgroup cols="4">
  641. <thead>
  642. <row>
  643. <entry>Option</entry>
  644. <entry>Data Type</entry>
  645. <entry>Default Value</entry>
  646. <entry>Description</entry>
  647. </row>
  648. </thead>
  649. <tbody>
  650. <row>
  651. <entry><emphasis>public_dir</emphasis></entry>
  652. <entry><type>String</type></entry>
  653. <entry><constant>NULL</constant></entry>
  654. <entry>
  655. Directory where to store static files. This must exist
  656. in your public directory.
  657. </entry>
  658. </row>
  659. <row>
  660. <entry><emphasis>file_locking</emphasis></entry>
  661. <entry><type>Boolean</type></entry>
  662. <entry><constant>TRUE</constant></entry>
  663. <entry>
  664. Enable or disable file_locking : Can avoid cache corruption under
  665. bad circumstances but it doesn't help on multithread webservers
  666. or on <acronym>NFS</acronym> filesystems...
  667. </entry>
  668. </row>
  669. <row>
  670. <entry><emphasis>read_control</emphasis></entry>
  671. <entry><type>Boolean</type></entry>
  672. <entry><constant>TRUE</constant></entry>
  673. <entry>
  674. Enable / disable read control : if enabled, a control key is
  675. embedded in the cache file and this key is compared with the
  676. one calculated after the reading.
  677. </entry>
  678. </row>
  679. <row>
  680. <entry><emphasis>read_control_type</emphasis></entry>
  681. <entry><type>String</type></entry>
  682. <entry>'crc32'</entry>
  683. <entry>
  684. Type of read control (only if read control is enabled). Available values
  685. are : 'md5' (best but slowest), 'crc32' (lightly less safe but faster,
  686. better choice), 'adler32' (new choice, faster than crc32),
  687. 'strlen' for a length only test (fastest).
  688. </entry>
  689. </row>
  690. <row>
  691. <entry><emphasis>cache_file_umask</emphasis></entry>
  692. <entry><type>Integer</type></entry>
  693. <entry>0600</entry>
  694. <entry>umask for cached files.</entry>
  695. </row>
  696. <row>
  697. <entry><emphasis>cache_directory_umask</emphasis></entry>
  698. <entry><type>Integer</type></entry>
  699. <entry>0700</entry>
  700. <entry>Umask for directories created within public_dir.</entry>
  701. </row>
  702. <row>
  703. <entry><emphasis>file_extension</emphasis></entry>
  704. <entry><type>String</type></entry>
  705. <entry>'<filename>.html</filename>'</entry>
  706. <entry>
  707. Default file extension for static files created. This can be
  708. configured on the fly, see
  709. <methodname>Zend_Cache_Backend_Static::save()</methodname> though
  710. generally it's recommended to rely on
  711. <classname>Zend_Controller_Action_Helper_Cache</classname> when
  712. doing so since it's simpler that way than messing with
  713. arrays or serialization manually.
  714. </entry>
  715. </row>
  716. <row>
  717. <entry><emphasis>index_filename</emphasis></entry>
  718. <entry><type>String</type></entry>
  719. <entry>'index'</entry>
  720. <entry>
  721. If a request <acronym>URI</acronym> does not contain sufficient
  722. information to construct a static file (usually this means an index
  723. call, e.g. <acronym>URI</acronym> of '/'), the index_filename is used
  724. instead. So '' or '/' would map to '<filename>index.html</filename>'
  725. (assuming the default file_extension is '<filename>.html</filename>').
  726. </entry>
  727. </row>
  728. <row>
  729. <entry><emphasis>tag_cache</emphasis></entry>
  730. <entry><type>Object</type></entry>
  731. <entry><constant>NULL</constant></entry>
  732. <entry>
  733. Used to set an 'inner' cache utilised to store tags
  734. and file extensions associated with static files. This
  735. <emphasis>must</emphasis> be set or the static cache cannot be tracked
  736. and managed.
  737. </entry>
  738. </row>
  739. <row>
  740. <entry><emphasis>disable_caching</emphasis></entry>
  741. <entry><type>Boolean</type></entry>
  742. <entry><constant>FALSE</constant></entry>
  743. <entry>
  744. If set to <constant>TRUE</constant>, static files will not be cached.
  745. This will force all requests to be dynamic even if marked
  746. to be cached in Controllers. Useful for debugging.
  747. </entry>
  748. </row>
  749. </tbody>
  750. </tgroup>
  751. </table>
  752. </sect2>
  753. </sect1>