cvs: smarty /docs/ru/programmers/caching caching-setting-up.xml
"Antony Dovgal" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvstony20011086344681@cvsserver> |
tony2001 Fri Jun 4 06:24:41 2004 EDT
Modified files:
/smarty/docs/ru/programmers/caching caching-setting-up.xml
Log:
add text translated by nw [ at ] webdevel [ dot ] ru
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
tony2001-20040604062441.txt
(text/plain, 12.9 KB)
http://cvs.php.net/diff.php/smarty/docs/ru/programmers/caching/caching-setting-up.xml?r1=1.1&r2=1.2&ty=u
Index: smarty/docs/ru/programmers/caching/caching-setting-up.xml
diff -u smarty/docs/ru/programmers/caching/caching-setting-up.xml:1.1 smarty/docs/ru/programmers/caching/caching-setting-up.xml:1.2
--- smarty/docs/ru/programmers/caching/caching-setting-up.xml:1.1 Tue Apr 13 07:46:22 2004
+++ smarty/docs/ru/programmers/caching/caching-setting-up.xml Fri Jun 4 06:24:41 2004
@@ -1,145 +1,165 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
- <sect1 id="caching.setting.up">
- <title>Setting Up Caching</title>
- <para>
- The first thing to do is enable caching. This is done by setting <link
- linkend="variable.caching">$caching</link> = true (or 1.)
- </para>
- <example>
- <title>enabling caching</title>
- <programlisting>
+<?xml version="1.0" encoding="windows-1251"?>
+<!-- $Revision: 1.2 $ -->
+<sect1 id="caching.setting.up">
+ <title>Íàñòðîéêà êýøèðîâàíèÿ</title>
+ <para>
+ Ïðåæäå âñåãî, êýøèðîâàíèå íåîáõîäèìî àêòèâèðîâàòü. Ýòî ìîæíî ñäåëàòü,
+ óñòàíîâèâ <link linkend="variable.caching">$caching</link> = true (èëè 1).
+ </para>
+ <example>
+ <title>Âêëþ÷åíèå êýøèðîâàíèÿ</title>
+ <programlisting>
+<![CDATA[
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;
-$smarty->display('index.tpl');</programlisting>
- </example>
- <para>
- With caching enabled, the function call to display('index.tpl') will render
- the template as usual, but also saves a copy of its output to a file (a
- cached copy) in the <link linkend="variable.cache.dir">$cache_dir</link>.
- Upon the next call to display('index.tpl'), the cached copy will be used
- instead of rendering the template again.
+$smarty->display('index.tpl');
+]]>
+ </programlisting>
+ </example>
+ <para>
+ Ïðè âêëþ÷åííîì êýøèðîâàíèè, âûçûâàåìàÿ ôóíêöèÿ display('index.tpl') èíòåðïðåòèðóåò
+ øàáëîí êàê îáû÷íî, íî òàêæå ñîõðàíÿåò êîïèþ âûâîäà â ôàéë (êýøèðîâàíóþ êîïèþ)
+ â <link linkend="variable.cache.dir">$cache_dir</link>.
+ Ïðè ñëåäóþùåì âûçîâå display('index.tpl'), âìåñòî ïîâòîðíîé èíòåðïðåòàöèè øàáëîíà,
+ áóäåò èñïîëüçîâàíà êåøèðîâàíàÿ êîïèÿ.
</para>
<note>
- <title>Technical Note</title>
- <para>
- The files in the $cache_dir are named similar to the template name.
- Although they end in the ".php" extention, they are not really executable
- php scripts. Do not edit these files!
- </para>
+ <title>Òåõíè÷åñêîå çàìå÷àíèå</title>
+ <para>
+ Ôàéëû â äèðåêòîðèè $cache_dir èìåþò òå æå èìåíà, ÷òî è ñîîòâåòñòâóþùèå
+ øàáëîíû. Èõ èìåíà îêàí÷èâàþòñÿ ðàñøèðåíèåì ".php", íî íà ñàìîì äåëå îíè íå ÿâëÿþòñÿ
+ âûïîëíÿåìûìè php-ñêðèïòàìè. Íå ðåäàêòèðóéòå ýòè ôàéëû!
+ </para>
</note>
<para>
- Each cached page has a limited lifetime determined by <link
- linkend="variable.cache.lifetime">$cache_lifetime</link>. The default value
- is 3600 seconds, or 1 hour. After that time expires, the cache is
- regenerated. It is possible to give individual caches their own expiration
- time by setting $caching = 2. See the documentation on <link
- linkend="variable.cache.lifetime">$cache_lifetime</link> for details.
- </para>
- <example>
- <title>setting cache_lifetime per cache</title>
- <programlisting>
+ Êàæäàÿ êýøèðîâàíàÿ ñòðàíè÷êà ñóùåñòâóåò íà ïðîòÿæåíèè îïðåäåëåííîãî âðåìåíè,
+ óêàçàííîãî â <link linkend="variable.cache.lifetime">$cache_lifetime</link>.
+ Çíà÷åíèå ïî óìîë÷àíèþ ðàâíî 3600 ñåêóíäàì èëè 1 ÷àñó. Ïîñëå òîãî, êàê ýòî âðåìÿ
+ èñòåêàåò, êýø îáíîâëÿåòñÿ. Ñóùåñòâóåò âîçìîæíîñòü ïðèñâîèòü êàæäîé
+ êýøèðîâàíîé ñòðàíè÷êå ñîáñòâåííîå âðåìÿ æèçíè, óñòàíîâèâ $caching = 2.
+ Ñìîòðèòå äîêóìåíòàöèþ <link linkend="variable.cache.lifetime">$cache_lifetime</link>
+ äëÿ ïîëó÷åíèÿ ïîäðîáíûõ ñâåäåíèé.
+ </para>
+ <example>
+ <title>Óñòàíîâêà ñîáñòâåííîãî cache_lifetime äëÿ êýøèðîâàíîé êîïèè</title>
+ <programlisting>
+<![CDATA[
require('Smarty.class.php');
$smarty = new Smarty;
-$smarty->caching = 2; // lifetime is per cache
+$smarty->caching = 2; // Ñðîê äåéñòâèÿ òîëüêî äëÿ ýòîé êîïèè
-// set the cache_lifetime for index.tpl to 5 minutes
+// óñòàíàâëèâàåì cache_lifetime äëÿ index.tpl â 5 ìèíóò
$smarty->cache_lifetime = 300;
$smarty->display('index.tpl');
-// set the cache_lifetime for home.tpl to 1 hour
+// óñòàíàâëèâàåì cache_lifetime äëÿ home.tpl â 1 ÷àñ
$smarty->cache_lifetime = 3600;
$smarty->display('home.tpl');
-// NOTE: the following $cache_lifetime setting will not work when $caching = 2.
-// The cache lifetime for home.tpl has already been set
-// to 1 hour, and will no longer respect the value of $cache_lifetime.
-// The home.tpl cache will still expire after 1 hour.
-$smarty->cache_lifetime = 30; // 30 seconds
-$smarty->display('home.tpl');</programlisting>
- </example>
- <para>
- If <link linkend="variable.compile.check">$compile_check</link> is enabled,
- every template file and config file that is involved with the cache file is
- checked for modification. If any of the files have been modified since the
- cache was generated, the cache is immediately regenerated. This is a slight
- overhead so for optimum performance, leave $compile_check set to false.
- </para>
- <example>
- <title>enabling $compile_check</title>
- <programlisting>
+// Ïðèìå÷àíèå: ñëåäóþùàÿ $cache_lifetime íàñòðîéêà íå áóäåò ðàáîòàòü, êîãäà $caching = 2.
+// Ñðîê æèçíè êýøà äëÿ home.tpl óæå áûë óñòàíîâëåí
+// â 1 ÷àñ, è Smarty áîëüøå íå áóäåò îáðàùàòü âíèìàíèå íà çíà÷åíèå $cache_lifetime.
+// Âðåìÿ æèçíè êýøà home.tpl ïî ïðåæíåìó áóäåò èñòåêàòü ïî ïðîøåñòâèþ îäíîãî ÷àñà.
+$smarty->cache_lifetime = 30; // 30 ñåêóíä
+$smarty->display('home.tpl');
+]]>
+ </programlisting>
+ </example>
+ <para>
+ Åñëè âêëþ÷åí ïàðàìåòð <link linkend="variable.compile.check">$compile_check</link>,
+ òî êàæäûé ôàéë øàáëîíà è êîíôèãóðàöèè, ñâÿçàííûé ñ ôàéëîì êýøà, ïðîâåðÿåòñÿ íà
+ íàëè÷èå èçìåíåíèé. Åñëè îäèí èç ýòèõ ôàéëîâ áûë ìîäèôèöèðîâàí ñ òåõ ïîð, êàê
+ êýø áûë ñîçäàí, êýø íåìåäëåííî îáíîâëÿåòñÿ. Ýòî íåçíà÷èòåëüíî ïîâûøàåò íàãðóçêó,
+ ïîýòîìó, äëÿ îïòèìàëüíîé ïðîèçâîäèòåëüíîñòè îñòàâüòå çíà÷åíèå $compile_check
+ ðàâíûì false.
+ </para>
+ <example>
+ <title>Âêëþ÷åíèå $compile_check</title>
+ <programlisting>
+<![CDATA[
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;
$smarty->compile_check = true;
-$smarty->display('index.tpl');</programlisting>
+$smarty->display('index.tpl');
+]]>
+ </programlisting>
</example>
<para>
- If <link linkend="variable.force.compile">$force_compile</link> is enabled,
- the cache files will always be regenerated. This effectively turns off
- caching. $force_compile is usually for debugging purposes only, a more
- efficient way of disabling caching is to set <link
- linkend="variable.caching">$caching</link> = false (or 0.)
- </para>
- <para>
- The <link linkend="api.is.cached">is_cached()</link> function
- can be used to test if a template has a valid cache or not. If you have a
- cached template that requires something like a database fetch, you can use
- this to skip that process.
- </para>
- <example>
- <title>using is_cached()</title>
- <programlisting>
+ Åñëè <link linkend="variable.force.compile">$force_compile</link>
+ àêòèâèðîâàí, ôàéëû êýøà âñåãäà áóäóò îáíîâëÿòüñÿ. Ýòî ñðåäñòâî ìîæíî
+ èñïîëüçîâàòü äëÿ îòêëþ÷åíèÿ êýøèðîâàíèÿ âî âðåìÿ îòëàäêè.
+ $force_compile îáû÷íî èñïîëüçóåòñÿ òîëüêî â öåëÿõ îòëàäêè, òàê êàê áîëåå
+ ïðàâèëüíûì ñïîñîáîì îòêëþ÷åíèÿ êåøèðîâàíèÿ ÿâëÿåòñÿ óñòàíîâêà
+ <link linkend="variable.caching">$caching</link> = false (èëè 0).
+ </para>
+ <para>
+ Ôóíêöèÿ <link linkend="api.is.cached">is_cached()</link> ìîæåò áûòü
+ èñïîëüçîâàíà äëÿ îïðåäåëåíèÿ, èìååòñÿ ëè ó øàáëîíà ðàáîòîñïîñîáíûé êýø.
+ Åñëè ó âàñ åñòü êýøèðîâàíûé øàáëîí, êîòîðîìó íåîáõîäèìî, íàïðèìåð,
+ ïîëó÷èòü âûáîðêó èç áàçû äàííûõ, âû ìîæåòå èñïîëüçîâàòü ýòó ôóíêöèþ,
+ ÷òîáû ïðîïóñòèòü ïðîöåññ îáðàùåíèÿ ê áàçå.
+ </para>
+ <example>
+ <title>Èñïîëüçîâàíèå is_cached()</title>
+ <programlisting>
+<![CDATA[
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;
if(!$smarty->is_cached('index.tpl')) {
- // No cache available, do variable assignments here.
+ // Êýø îòñóòñòâóåò, çíà÷èò ïðèñâàåâàåì çíà÷åíèÿ ïåðåìåííûì.
$contents = get_database_contents();
$smarty->assign($contents);
}
-$smarty->display('index.tpl');</programlisting>
- </example>
- <para>
- You can keep parts of a page dynamic with the <link
- linkend="language.function.insert">insert</link> template function. Let's
- say the whole page can be cached except for a banner that is displayed down
- the right side of the page. By using an insert function for the banner, you
- can keep this element dynamic within the cached content. See the
- documentation on <link linkend="language.function.insert">insert</link> for
- details and examples.
- </para>
- <para>
- You can clear all the cache files with the <link
- linkend="api.clear.all.cache">clear_all_cache()</link> function, or
- individual cache files (or groups) with the <link
- linkend="api.clear.cache">clear_cache()</link> function.
- </para>
- <example>
- <title>clearing the cache</title>
- <programlisting>
+$smarty->display('index.tpl');
+]]>
+ </programlisting>
+ </example>
+ <para>
+ Âû ìîæåòå ñäåëàòü òàê, ÷òîáû ÷àñòü ñòðàíèöû îñòàâàëàñü äèíàìè÷åñêîé, äàæå
+ åñëè ñòðàíèöà êýøèðóåòñÿ, ïðè ïîìîùè âñòðîåííîé ôóíêöèè <link
+ linkend="language.function.insert">insert</link>. Íàïðèìåð,
+ êýøèðîâàòüñÿ ìîæåò âñÿ ñòðàíèöà, çà èñêëþ÷åíèåì áàííåðà.
+ Èñïîëüçóÿ ôóíêöèþ insert äëÿ áàííåðà, âû ìîæåòå ñîõðàíÿòü
+ ýòîò ýëåìåíò äèíàìè÷íûì, âíóòðè êýøèðîâàíîé ñòðàíè÷êè. Ñìîòðèòå
+ äîêóìåíòàöèþ ïî <link linkend="language.function.insert">insert</link> äëÿ
+ ïîëó÷åíèÿ ïîäðîáíîñòåé è ïðèìåðîâ.
+ </para>
+ <para>
+ Î÷èñòèòü âñå ôàéëû êýøà ìîæíî ïðè ïîìîùè ôóíêöèè
+ <link linkend="api.clear.all.cache">clear_all_cache()</link>, à
+ êîíêðåòíûé ôàéë êýøà (èëè ãðóïïó) - âûçâàâ
+ <link linkend="api.clear.cache">clear_cache()</link> ôóíêöèþ.
+ </para>
+ <example>
+ <title>Î÷èñòêà êýøà</title>
+ <programlisting>
+<![CDATA[
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;
-// clear out all cache files
+// î÷èùàåì âñå ôàéëû êýøà
$smarty->clear_all_cache();
-// clear only cache for index.tpl
+// î÷èùàåì òîëüêî êýø øàáëîíà index.tpl
$smarty->clear_cache('index.tpl');
-$smarty->display('index.tpl');</programlisting>
- </example>
+$smarty->display('index.tpl');
+]]>
+ </programlisting>
+ </example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -160,4 +180,4 @@
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
--->
\ No newline at end of file
+-->