Zend_Cache-Frontends.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <sect1 id="zend.cache.frontends">
  2. <title>الـ frontends المتوفرة فى Zend_Cache</title>
  3. <sect2 id="zend.cache.core">
  4. <title>Zend_Cache_Core</title>
  5. <sect3 id="zend.cache.core.introduction">
  6. <title>مقدمة</title>
  7. <para>
  8. <code>Zend_Cache_Core</code> هو frontend مميز لأنه جوهر الـ module .
  9. هو عبارة cache frontend عام و هناك classes أخرى ممتدة منه.
  10. </para>
  11. <note><para>
  12. كل الـ frontends ترث من <code>Zend_Cache_Core</code> و بهذا كل الـ methods
  13. و الـ options الخاصة به (سيتم توضيحها لاحقاً) متوفرة فى الـ frontends الأخرى , لذلك لن نقوم بشرحها هناك.
  14. </para></note>
  15. </sect3>
  16. <sect3 id="zend.cache.core.options">
  17. <title>الـ options المتوفرة</title>
  18. <para>
  19. هذه الـ options يتم تمريرها الى الـ factory method كما كان موضحاً فى امثلة سابقة.
  20. </para>
  21. <table>
  22. <title>الـ options المتوفرة لـ Zend_Cache_Core</title>
  23. <tgroup cols="4">
  24. <thead>
  25. <row>
  26. <entry>الـ Option</entry>
  27. <entry>الـ Data Type</entry>
  28. <entry>الـ Default Value</entry>
  29. <entry>الوصف</entry>
  30. </row>
  31. </thead>
  32. <tbody>
  33. <row>
  34. <entry><code>caching</code></entry>
  35. <entry><code>boolean</code></entry>
  36. <entry><code>true</code></entry>
  37. <entry>
  38. تقوم بإقاف او تشغيل عملية الـ caching ( من الممكن ان تكن مفيدة عند عمل debuging للكود الواقع فى
  39. نطاق عمل عملية الـ caching ).
  40. </entry>
  41. </row>
  42. <row>
  43. <entry><code>lifeTime</code></entry>
  44. <entry><code>int</code></entry>
  45. <entry><code>3600</code></entry>
  46. <entry>
  47. فترة صلاحية الـ cache record (بالثوانى), إن كانت قيمتها تساوى null فسيكون الـ cache record
  48. صالح للإستخدام دائما.
  49. </entry>
  50. </row>
  51. <row>
  52. <entry><code>logging</code></entry>
  53. <entry><code>boolean</code></entry>
  54. <entry><code>false</code></entry>
  55. <entry>
  56. إن كانت قيمتها تساوى TRUE, سيتم تنشيط عملية الـ loging من خلال <code>Zend_Log</code> .
  57. (لكن سيبطئ من عمل النظام نسبياً)
  58. </entry>
  59. </row>
  60. <row>
  61. <entry><code>writeControl</code></entry>
  62. <entry><code>boolean</code></entry>
  63. <entry><code>true</code></entry>
  64. <entry>
  65. تقوم بايقاف او تشغيل الـ write control (أى سيتم قرائة الـ cache بعد حفظه للتأكد من
  66. عدم وجود اخطاء به).
  67. تشغيل الـ write control سيتسبب فى ابطاء عملية كتابة "حفظ" الـ cache قليلا, لكنه
  68. لن يؤثر فى علية القرائة.
  69. (يمكن ان بساعد فى اكتشاف ملفات الـ cache المعطوبة "الفاسدة" و لكنه برغم ذالك لا يعتبر
  70. control ممتاز )
  71. </entry>
  72. </row>
  73. <row>
  74. <entry><code>automaticSerialization</code></entry>
  75. <entry><code>boolean</code></entry>
  76. <entry><code>false</code></entry>
  77. <entry>
  78. تقوم بتشغيل او ايقاف عملية الـ serialization التلقائية , يمكن ان يتم استخدامها عند الحاجة لحفظ
  79. بيانات مباشرة , حيث ان هذه البيانات ليست من النوع string.
  80. (لكنها ابطء)
  81. </entry>
  82. </row>
  83. <row>
  84. <entry><code>automaticCleaningFactor</code></entry>
  85. <entry><code>int</code></entry>
  86. <entry><code>10</code></entry>
  87. <entry>
  88. تقوم بتشغيل او ايقاف عملية التنظيف (garbage collector):
  89. القيمة 0 تعنى إيقاف عملية التنظيف التلقائى للـ cache ,
  90. القيمة 1 تعنى تشغيل عملية التنظيف بشكل منتظم,
  91. و عندما تكن القيمة هى x &gt; 1 سيتم تنفيذ عملية تنظيف تلقائى عشوائية لكل عدد x من
  92. عمليات الكتابة.
  93. </entry>
  94. </row>
  95. </tbody>
  96. </tgroup>
  97. </table>
  98. </sect3>
  99. <sect3 id="zend.cache.core.examples">
  100. <title>امثلة</title>
  101. <para>
  102. تم اعطاء مثال فى بداية هذا الفصل.
  103. </para>
  104. <para>
  105. إن كنت تقم بحفظ بيانات من النوع string فقط فى الـ cache (من الممكن حفظ
  106. بيانات من النوع bool ايضا بتشغيل الـ option المسمى "automaticSerialization" ) ,
  107. يمكنك ان تستخدم بنية كود ادق مثل هذه :
  108. </para>
  109. <programlisting role="php"><![CDATA[<?php
  110. // we assume you already have $cache
  111. $id = 'myBigLoop'; // cache id of "what we want to cache"
  112. if (!($data = $cache->load($id))) {
  113. // cache miss
  114. $data = '';
  115. for ($i = 0; $i < 10000; $i++) {
  116. $data = $data . $i;
  117. }
  118. $cache->save($data);
  119. }
  120. // [...] do something with $data (echo it, pass it on etc.)
  121. ?>]]> </programlisting>
  122. <para>
  123. إن كنت تريد حفظ اكثر من بلوك او مجموعة بيانات مختلفة, فهى نفس الفكرة :
  124. </para>
  125. <programlisting role="php"><![CDATA[<?php
  126. // make sure you use unique identifiers:
  127. $id1 = 'foo';
  128. $id2 = 'bar';
  129. // block 1
  130. if (!($data = $cache->load($id1))) {
  131. // cache missed
  132. $data = '';
  133. for ($i=0;$i<10000;$i++) {
  134. $data = $data . $i;
  135. }
  136. $cache->save($data);
  137. }
  138. echo($data);
  139. // this isn't affected by caching
  140. echo('NEVER CACHED! ');
  141. // block 2
  142. if (!($data = $cache->load($id2))) {
  143. // cache missed
  144. $data = '';
  145. for ($i=0;$i<10000;$i++) {
  146. $data = $data . '!';
  147. }
  148. $cache->save($data);
  149. }
  150. echo($data);
  151. ?>]]> </programlisting>
  152. </sect3>
  153. </sect2>
  154. <sect2 id="zend.cache.frontend.output">
  155. <title>Zend_Cache_Frontend_Output</title>
  156. <sect3 id="zend.cache.frontend.output.introduction">
  157. <title>مقدمة</title>
  158. <para>
  159. <code>Zend_Cache_Frontend_Output</code> هو frontend يستخدم فى التقاط البيانات
  160. المخرجة. يستخدم خاصية الـ output buffering التى تقدمها لغة PHP ليلتقط كل شئ يتم اخراجه بين
  161. الـ methods المسمى <code>()start</code> و <code>()end</code>.
  162. </para>
  163. </sect3>
  164. <sect3 id="zend.cache.frontend.output.options">
  165. <title>الـ options المتوفرة</title>
  166. <para>
  167. هذا الـ frontend لا يحتوى اى options جديدة بخلاف الموجودة فى
  168. <code>Zend_Cache_Core</code>.
  169. </para>
  170. </sect3>
  171. <sect3 id="zend.cache.frontend.output.examples">
  172. <title>امثلة</title>
  173. <para>
  174. تم اعطاء مثال فى بداية هذا الفصل, ها هو مع بعض التعديلات الصغيرة:
  175. </para>
  176. <programlisting role="php"><![CDATA[<?php
  177. // if it is a cache miss, output buffering is triggered
  178. if(!$cache->start('mypage')):
  179. // output everything as usual
  180. echo 'Hello world! ';
  181. echo 'This is cached ('.time().') ';
  182. $cache->end(); // output buffering ends
  183. endif;
  184. echo 'This is never cached ('.time().').';
  185. ?>]]> </programlisting>
  186. <para>
  187. بإستخدام هذه الطريقة يمكنك بسهولة إدخال خاصية الـ caching لمخرجات الأكواد فى مشروعك بإستخدام القليل او
  188. ربما عدم الأحتياج لعمل refactoring.
  189. </para>
  190. </sect3>
  191. </sect2>
  192. <sect2 id="zend.cache.frontend.function">
  193. <title>Zend_Cache_Frontend_Function</title>
  194. <sect3 id="zend.cache.frontend.function.introduction">
  195. <title>مقدمة</title>
  196. <para>
  197. تقوم <code>Zend_Cache_Frontend_Function</code> بعمل cache
  198. لناتج استدعاء دالة ما, و لديها method واحد رئيسى يسمى <code>()call</code> و الذى
  199. يأخذ اسم الدالة المراد استدعائها و array تحتوتى الـ parameters التى سيتم تمريرها لهذه الدالة.
  200. </para>
  201. </sect3>
  202. <sect3 id="zend.cache.frontend.function.options">
  203. <title>الـ options المتوفرة</title>
  204. <table>
  205. <title>الـ options المتوفرة لـ Zend_Cache_Frontend_Function</title>
  206. <tgroup cols="4">
  207. <thead>
  208. <row>
  209. <entry>الـ Option</entry>
  210. <entry>الـ Data Type</entry>
  211. <entry>الـ Default Value</entry>
  212. <entry>الوصف</entry>
  213. </row>
  214. </thead>
  215. <tbody>
  216. <row>
  217. <entry><code>cacheByDefault</code></entry>
  218. <entry><code>boolean</code></entry>
  219. <entry><code>true</code></entry>
  220. <entry>
  221. إن كانت قيمتها true , سيتم تنفيذ عملية الـ cache لكل عملية استدعاء دالة (by default).
  222. </entry>
  223. </row>
  224. <row>
  225. <entry><code>cachedFunctions</code></entry>
  226. <entry><code>array</code></entry>
  227. <entry></entry>
  228. <entry>
  229. اسماء الـ functions التى سيتم عمل cache لها دائما.
  230. </entry>
  231. </row>
  232. <row>
  233. <entry><code>nonCachedFunctions</code></entry>
  234. <entry><code>array</code></entry>
  235. <entry></entry>
  236. <entry>
  237. اسماء الـ functions التى لا يجب عمل cache لها ابدا.
  238. </entry>
  239. </row>
  240. </tbody>
  241. </tgroup>
  242. </table>
  243. </sect3>
  244. <sect3 id="zend.cache.frontend.function.examples">
  245. <title>امثلة</title>
  246. <para>
  247. استخدام الـ method المسمى <code>()call</code> هو نفس طريقة استخدام
  248. دالة لغة PHP المسمى <code>()call_user_func_array</code> :
  249. </para>
  250. <programlisting role="php"><![CDATA[<?php
  251. $cache->call('veryExpensiveFunc', $params);
  252. # $params is an array
  253. # for example to call (with caching) veryExpensiveFunc(1, 'foo', 'bar'), you will use
  254. # $cache->call('veryExpensiveFunc', array(1, 'foo', 'bar'))
  255. ?>]]> </programlisting>
  256. <para>
  257. <code>Zend_Cache_Frontend_Function</code> ذكية كفاية لتقوم بعمل
  258. cache لكل من ناتج الدالة العائد من "return" و البيانات المخرجة داخل الدالة (مثل عمل طباعة
  259. لبعض البيانات من داخل الدالة).
  260. </para>
  261. <note><para>
  262. يمكنك تمرير اى دالة سواء كانت من دوال اللغة او دالة انت انشئتها بإستثناء الدوال التالية :
  263. <code>array</code>,
  264. <code>echo</code>,
  265. <code>empty</code>,
  266. <code>eval</code>,
  267. <code>exit</code>,
  268. <code>isset</code>,
  269. <code>list</code>
  270. , <code>print</code>
  271. <code>unset</code>.
  272. </para></note>
  273. </sect3>
  274. </sect2>
  275. <sect2 id="zend.cache.frontend.class">
  276. <title>Zend_Cache_Frontend_Class</title>
  277. <sect3 id="zend.cache.frontend.class.introduction">
  278. <title>مقدمة</title>
  279. <para>
  280. يختلف <code>Zend_Cache_Frontend_Class</code> عن
  281. <code>Zend_Cache_Frontend_Function</code> حيث انه
  282. يقوم بعمل cache لعمليات استدعاء الـ objects و الـ static methods.
  283. </para>
  284. </sect3>
  285. <sect3 id="zend.cache.frontend.class.options">
  286. <title>الـ options المتوفر</title>
  287. <table>
  288. <title>الـ options المتوفرة لـ Zend_Cache_Frontend_Class</title>
  289. <tgroup cols="4">
  290. <thead>
  291. <row>
  292. <entry>الـ Option</entry>
  293. <entry>الـ Data Type</entry>
  294. <entry>الـ Default Value</entry>
  295. <entry>الوصف</entry>
  296. </row>
  297. </thead>
  298. <tbody>
  299. <row>
  300. <entry><code>cachedEntity</code> (مطلوب)</entry>
  301. <entry><code>mixed</code></entry>
  302. <entry></entry>
  303. <entry>
  304. إن كانت قيمتها عبارة عن اسم class, سيتم عمل cache للـ class على انه abstract
  305. و سيتم استخدام طلبات الـ static mithods الخاصة به.
  306. إذا كانت قيمتها عبارة عن object, سيتم عمل cache لكل الـ methods الخاصة
  307. بهذا الـ object.
  308. </entry>
  309. </row>
  310. <row>
  311. <entry><code>cacheByDefault</code></entry>
  312. <entry><code>boolean</code></entry>
  313. <entry><code>true</code></entry>
  314. <entry>
  315. إن كانت تحمل القيمة true, كل الطلبات "calls" سيتم عمل cache لها تلقائيا.
  316. </entry>
  317. </row>
  318. <row>
  319. <entry><code>cachedMethods</code></entry>
  320. <entry><code>array</code></entry>
  321. <entry></entry>
  322. <entry>
  323. اسماء الـ methods التى يستم عمل cache لها دائما.
  324. </entry>
  325. </row>
  326. <row>
  327. <entry><code>nonCachedMethods</code></entry>
  328. <entry><code>array</code></entry>
  329. <entry></entry>
  330. <entry>
  331. اسماء الـ methods التى لا يجب عمل cache لها ابدا.
  332. </entry>
  333. </row>
  334. </tbody>
  335. </tgroup>
  336. </table>
  337. </sect3>
  338. <sect3 id="zend.cache.frontend.class.examples">
  339. <title>امثلة</title>
  340. <para>
  341. مثال على عمل cache لأستدعائات الـ static methods:
  342. </para>
  343. <programlisting role="php"><![CDATA[<?php
  344. class test {
  345. # Static method
  346. public static function foobar($param1, $param2) {
  347. echo "foobar_output($param1, $param2)";
  348. return "foobar_return($param1, $param2)";
  349. }
  350. }
  351. // [...]
  352. $frontendOptions = array(
  353. 'cachedEntity' => 'test' // The name of the class
  354. );
  355. // [...]
  356. # The cached call
  357. $res = $cache->foobar('1', '2');
  358. ?>]]> </programlisting>
  359. <para>
  360. لعمل cache للـ methods العادية:
  361. </para>
  362. <programlisting role="php"><![CDATA[<?php
  363. class test {
  364. private $_string = 'hello !';
  365. public function foobar2($param1, $param2) {
  366. echo($this->_string);
  367. echo "foobar2_output($param1, $param2)";
  368. return "foobar2_return($param1, $param2)";
  369. }
  370. }
  371. // [...]
  372. $frontendOptions = array(
  373. 'cachedEntity' => new test() // An instance of the class
  374. );
  375. // [...]
  376. # The cached call
  377. $res = $cache->foobar2('1', '2');
  378. ?>]]> </programlisting>
  379. </sect3>
  380. </sect2>
  381. <sect2 id="zend.cache.frontends.file">
  382. <title>Zend_Cache_Frontend_File</title>
  383. <sect3 id="zend.cache.frontends.file.introduction">
  384. <title>مقدمة</title>
  385. <para>
  386. <code>Zend_Cache_Frontend_File</code> هو frontend يعتمد
  387. على اخر وقت تعديل ملف معين "master file".
  388. يتم استخدامه على سبيل المثال مع ملفات الـ configuration او الملفات التى تخص
  389. الـ templating.
  390. </para>
  391. <para>
  392. على سبيل المثال: انت لديك ملف XML يحتوى على الـ configurations الخاصة ببرنامجك,
  393. هذا الملف يتم قرائة محتوياته بإستخدام دالة معينة و التى تعيد "return" إلينا "config object"
  394. (مثل <code>Zend_Config</code> ).
  395. عن طريق <code>Zend_Cache_Frontend_File</code> يمكنك
  396. حفظ الـ "config object" فى الـ cache (لتتجنب عملية قرائة ملف الـ XML عند كل مرة)
  397. لكن بالأعتماد بشدة على الـ "master file" اى ملف الـ XML.
  398. إذاً, إن تم تعديل ملف الـ XML سيتم اعتبار النسخة فى الـ cache غير صالحة للإستخدام و سيتم إنشاء
  399. اخرى جديدة.
  400. </para>
  401. </sect3>
  402. <sect3 id="zend.cache.frontends.file.options">
  403. <title>الـ options المتوفرة</title>
  404. <table>
  405. <title>الـ options المتوفرة لـ Zend_Cache_Frontend_File</title>
  406. <tgroup cols="4">
  407. <thead>
  408. <row>
  409. <entry>الـ Option</entry>
  410. <entry>الـ Data Type</entry>
  411. <entry>الـ Default Value</entry>
  412. <entry>الوصف</entry>
  413. </row>
  414. </thead>
  415. <tbody>
  416. <row>
  417. <entry><code>masterFile (إجبارى)</code></entry>
  418. <entry><code>string</code></entry>
  419. <entry><code></code></entry>
  420. <entry>
  421. المسار الكامل للملف "master file".
  422. </entry>
  423. </row>
  424. </tbody>
  425. </tgroup>
  426. </table>
  427. </sect3>
  428. <sect3 id="zend.cache.frontends.file.examples">
  429. <title>امثلة</title>
  430. <para>
  431. إستخدام هذا الـ frontend هو نفس طريقة استخدام <code>Zend_Cache_Core</code>,
  432. لذلك لا يوجد حاجة إلى مثال جديد, الشئ الوحيد الذى ستقوم به هو تعريف قيمة
  433. <code>masterFile</code> عند إستخدام الـ factory.
  434. </para>
  435. </sect3>
  436. </sect2>
  437. <sect2 id="zend.cache.frontends.page">
  438. <title>Zend_Cache_Frontend_Page</title>
  439. <sect3 id="zend.cache.frontends.page.introduction">
  440. <title>مقدمة</title>
  441. <para>
  442. <code>Zend_Cache_Frontend_Page</code> يتشابه مع
  443. <code>Zend_Cache_Frontend_Output</code> إلا انه تم تصميمه
  444. لعمل cache لصفحة كاملة.
  445. فلا يمكن إستخدام <code>Zend_Cache_Frontend_Page</code>
  446. لعمل cache لجزء او بلوك معين فقط.
  447. </para>
  448. <para>
  449. على الجانب الأخر, الـ "cache id" يتم حسابه من خلال
  450. <code>['SERVER['REQUEST_URI_$</code> و (اعتمادا على قيم الـ options يستخدم التالى)
  451. <code>GET</code>, <code>POST</code>,
  452. <code>SESSION</code>, <code>COOKIE</code>,
  453. <code>FILES</code>.
  454. غير ذلك, يجب عليك استدعاء method واحد فقط و هو (<code>()start</code>) لأن
  455. <code>()end</code> يتم إستدعائه تلقائيا عند إنتهاء الصفحة.
  456. </para>
  457. <para>
  458. الى هذه اللحظة لم يتم تنفيذه لكننا ننوى إضافة نظام HTTP شرطى لحفظ المذيد من الـ bandwith
  459. (سيقوم النظام بإرسال الهيدر "HTTP 304" أى لم يتم تعديل الملف و هذا إذا تم إيجاد نسخة cache
  460. قابلة للأستخدام "طازجة" و إذا كان لدى المتصفح ايضا نسخة صالحة "طازجة" من هذه الصفحة.
  461. </para>
  462. <note><para>
  463. Zend_Cache_Frontend_Page يعتبر فى المرحلة alpha الأن , إى انه سيتم عمل
  464. تطويرات جديدة له مع مرور الوقت.
  465. </para></note>
  466. </sect3>
  467. <sect3 id="zend.cache.frontends.page.options">
  468. <title>الـ options المتوفرة</title>
  469. <table>
  470. <title>الـ options المتوفرة لـ Zend_Cache_Frontend_Page</title>
  471. <tgroup cols="4">
  472. <thead>
  473. <row>
  474. <entry>الـ Option</entry>
  475. <entry>الـ Data Type</entry>
  476. <entry>الـ Default Value</entry>
  477. <entry>الوصف</entry>
  478. </row>
  479. </thead>
  480. <tbody>
  481. <row>
  482. <entry><code>httpConditional</code></entry>
  483. <entry><code>boolean</code></entry>
  484. <entry><code>false</code></entry>
  485. <entry>
  486. إستخدم نظام الـ HTTP الشرطى "httpConditional system" (لم يتم دعمه الى الأن).
  487. </entry>
  488. </row>
  489. <row>
  490. <entry><code>debugHeader</code></entry>
  491. <entry><code>boolean</code></entry>
  492. <entry><code>false</code></entry>
  493. <entry>
  494. إن كانت تحمل القيمة true, بيانات الـ debugging سيتم إضافتها قبل كل صفحة لها cache.
  495. </entry>
  496. </row>
  497. <row>
  498. <entry><code>defaultOptions</code></entry>
  499. <entry><code>array</code></entry>
  500. <entry><code>(.انظر الوصف.)array</code></entry>
  501. <entry>
  502. associative array تحتوى على الـ default options :
  503. <itemizedlist>
  504. <listitem>
  505. <para>
  506. <code>(boolean, true by default) cache</code> :
  507. إن كانت تحمل قيمة true فالـ cache مفعل
  508. </para>
  509. </listitem>
  510. <listitem>
  511. <para>
  512. <code>(boolean, false by default) cacheWithGetVariables</code> :
  513. إن كانت تحمل القيمة true فالـ cache مفعل حتى لو كان هناك قيم فى المصفوفة
  514. <code>GET_$</code>
  515. </para>
  516. </listitem>
  517. <listitem>
  518. <para>
  519. <code>(boolean, false by default) cacheWithPostVariables</code> :
  520. إن كانت تحمل القيمة true فالـ cache مفعل حتى لو كان هناك قيم فى المصفوفة
  521. <code>POST_$</code>
  522. </para>
  523. </listitem>
  524. <listitem>
  525. <para>
  526. <code>(boolean, false by default) cacheWithSessionVariables</code> :
  527. إن كانت تحمل القيمة true فالـ cache مفعل حتى لو كان هناك قيم فى المصفوفة
  528. <code>SESSION_$</code>
  529. </para>
  530. </listitem>
  531. <listitem>
  532. <para>
  533. <code>(boolean, false by default) cacheWithFilesVariables</code> :
  534. إن كانت تحمل القيمة true فالـ cache مفعل حتى لو كان هناك قيم فى المصفوفة
  535. <code>FILES_$</code>
  536. </para>
  537. </listitem>
  538. <listitem>
  539. <para>
  540. <code>(boolean, false by default) cacheWithCookieVariables</code> :
  541. إن كانت تحمل القيمة true فالـ cache مفعل حتى لو كان هناك قيم فى المصفوفة
  542. <code>COOKIE_$</code>
  543. </para>
  544. </listitem>
  545. <listitem>
  546. <para>
  547. <code>(boolean, true by default) makeIdWithGetVariables</code> :
  548. إن كانت تحمل القيمة true فقيمة الـ "cache id" تعتمد على محتويات المصفوفة
  549. <code>GET_$</code>
  550. </para>
  551. </listitem>
  552. <listitem>
  553. <para>
  554. <code>(boolean, true by default) makeIdWithPostVariables</code> :
  555. إن كانت تحمل القيمة true فقيمة الـ "cache id" تعتمد على محتويات المصفوفة
  556. <code>POST_$</code>
  557. </para>
  558. </listitem>
  559. <listitem>
  560. <para>
  561. <code>(boolean, true by default) makeIdWithSessionVariables</code> :
  562. إن كانت تحمل القيمة true فقيمة الـ "cache id" تعتمد على محتويات المصفوفة
  563. <code>SESSION_$</code>
  564. </para>
  565. </listitem>
  566. <listitem>
  567. <para>
  568. <code>(boolean, true by default) makeIdWithFilesVariables</code> :
  569. إن كانت تحمل القيمة true فقيمة الـ "cache id" تعتمد على محتويات المصفوفة
  570. <code>FILES_$</code>
  571. </para>
  572. </listitem>
  573. <listitem>
  574. <para>
  575. <code>(boolean, true by default) makeIdWithCookieVariables</code> :
  576. إن كانت تحمل القيمة true فقيمة الـ "cache id" تعتمد على محتويات المصفوفة
  577. <code>COOKIE_$</code>
  578. </para>
  579. </listitem>
  580. </itemizedlist>
  581. </entry>
  582. </row>
  583. <row>
  584. <entry><code>regexps</code></entry>
  585. <entry><code>array</code></entry>
  586. <entry><code>array()</code></entry>
  587. <entry>
  588. associative array تضع بها الـ options الخاصة بـ REQUEST_URI.
  589. المفتاح "key" سيكون عبارة عن جملة regex من النوع (PCRE), و القيم "values"
  590. ستكون عبارة عن associative array تحتوى مجموعة من الـ options التى سيتم
  591. تنفيذها إذا توافقت جملة الـ regex مع ['SERVER['REQUEST_URI_$
  592. (انظر الى defaultOptions لقائمة بالـ options المتوفرة).
  593. إذا توافقت اكثر من جملة regexp مع قيمة ['SERVER['REQUEST_URI_$ , سيتم
  594. إستخدام اخر واحد فقط.
  595. </entry>
  596. </row>
  597. </tbody>
  598. </tgroup>
  599. </table>
  600. </sect3>
  601. <sect3 id="zend.cache.frontends.page.examples">
  602. <title>امثلة</title>
  603. <para>
  604. إستخدام Zend_Cache_Frontend_Page سهل جدا :
  605. </para>
  606. <programlisting role="php"><![CDATA[<?php
  607. // [...] // require, configuration and factory
  608. $cache->start();
  609. // if the cache is hit, the result is sent to the browser and the script stop here
  610. // rest of the page ...
  611. ?>]]> </programlisting>
  612. <para>
  613. مثال اكثر تعقيدا يوضح اسلوب لتنفيذ إدارة مركزية للـ cache داخل ملف bootstrap
  614. "ملف رئيسى لتشغيل البرنامج".
  615. (مثلا للإستخدام مع Zend_Controller)
  616. </para>
  617. <programlisting role="php"><![CDATA[<?php
  618. // [...] you should avoid to put too much lines before the cache section
  619. // [...] for example, for optimal performances, "require_once" or "Zend_Loader::loadClass" should be
  620. // [...] after the cache section
  621. require_once 'Zend/Cache.php';
  622. $frontendOptions = array(
  623. 'lifeTime' => 7200,
  624. 'debugHeader' => true, // for debuging
  625. 'regexps' => array(
  626. '^/$' => array('cache' => true), // cache the whole IndexController
  627. '^/index/' => array('cache' => true), // cache the whole IndexController
  628. '^/article/' => array('cache' => false), // we don't cache the ArticleController...
  629. '^/article/view/' => array( // ...but we cache the "view" action of
  630. 'cache' => true, // this ArticleController
  631. 'cacheWithPostVariables' => true, // and we cache even there are some variables in $_POST
  632. 'makeIdWithPostVariables' => true, // (but the cache will be dependent of the $_POST array)
  633. )
  634. )
  635. );
  636. $backendOptions = array(
  637. 'cacheDir' => '/tmp/'
  638. );
  639. // getting a Zend_Cache_Frontend_Page object
  640. $cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
  641. $cache->start();
  642. // if the cache is hit, the result is sent to the browser and the script stop here
  643. // [...] the end of the bootstrap file (these lines won't be executed if the cache is hit)
  644. ?>]]> </programlisting>
  645. </sect3>
  646. </sect2>
  647. </sect1>