diff --git a/docs/ru/programmers/caching/caching-setting-up.xml b/docs/ru/programmers/caching/caching-setting-up.xml index c63c8a11..68516fa6 100644 --- a/docs/ru/programmers/caching/caching-setting-up.xml +++ b/docs/ru/programmers/caching/caching-setting-up.xml @@ -1,145 +1,165 @@ - + - - Setting Up Caching - - The first thing to do is enable caching. This is done by setting $caching = true (or 1.) - - - enabling caching - + + Настройка кэширования + + Прежде всего, кэширование необходимо активировать. Это можно сделать, + установив $caching = true (или 1). + + + Включение кэширования + +caching = true; -$smarty->display('index.tpl'); - +$smarty->display('index.tpl'); +]]> + + - 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 $cache_dir. - Upon the next call to display('index.tpl'), the cached copy will be used - instead of rendering the template again. + При включенном кэшировании, вызываемая функция display('index.tpl') интерпретирует + шаблон как обычно, но также сохраняет копию вывода в файл (кэшированую копию) + в $cache_dir. + При следующем вызове display('index.tpl'), вместо повторной интерпретации шаблона, + будет использована кешированая копия. - Technical Note - - 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! - + Техническое замечание + + Файлы в директории $cache_dir имеют те же имена, что и соответствующие + шаблоны. Их имена оканчиваются расширением ".php", но на самом деле они не являются + выполняемыми php-скриптами. Не редактируйте эти файлы! + - Each cached page has a limited lifetime determined by $cache_lifetime. 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 $cache_lifetime for details. + Каждая кэшированая страничка существует на протяжении определенного времени, + указанного в $cache_lifetime. + Значение по умолчанию равно 3600 секундам или 1 часу. После того, как это время + истекает, кэш обновляется. Существует возможность присвоить каждой + кэшированой страничке собственное время жизни, установив $caching = 2. + Смотрите документацию $cache_lifetime + для получения подробных сведений. - - setting cache_lifetime per cache - + + Установка собственного cache_lifetime для кэшированой копии + +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'); - +// Примечание: следующая $cache_lifetime настройка не будет работать, когда $caching = 2. +// Срок жизни кэша для home.tpl уже был установлен +// в 1 час, и Smarty больше не будет обращать внимание на значение $cache_lifetime. +// Время жизни кэша home.tpl по прежнему будет истекать по прошествию одного часа. +$smarty->cache_lifetime = 30; // 30 секунд +$smarty->display('home.tpl'); +]]> + + - If $compile_check 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. + Если включен параметр $compile_check, + то каждый файл шаблона и конфигурации, связанный с файлом кэша, проверяется на + наличие изменений. Если один из этих файлов был модифицирован с тех пор, как + кэш был создан, кэш немедленно обновляется. Это незначительно повышает нагрузку, + поэтому, для оптимальной производительности оставьте значение $compile_check + равным false. - - enabling $compile_check - + + Включение $compile_check + +caching = true; $smarty->compile_check = true; -$smarty->display('index.tpl'); +$smarty->display('index.tpl'); +]]> + - If $force_compile 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 $caching = false (or 0.) - + Если $force_compile + активирован, файлы кэша всегда будут обновляться. Это средство можно + использовать для отключения кэширования во время отладки. + $force_compile обычно используется только в целях отладки, так как более + правильным способом отключения кеширования является установка + $caching = false (или 0). + - The is_cached() 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. + Функция is_cached() может быть + использована для определения, имеется ли у шаблона работоспособный кэш. + Если у вас есть кэшированый шаблон, которому необходимо, например, + получить выборку из базы данных, вы можете использовать эту функцию, + чтобы пропустить процесс обращения к базе. - - using is_cached() - + + Использование is_cached() + +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'); - +$smarty->display('index.tpl'); +]]> + + - You can keep parts of a page dynamic with the insert 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 insert for - details and examples. + Вы можете сделать так, чтобы часть страницы оставалась динамической, даже + если страница кэшируется, при помощи встроенной функции insert. Например, + кэшироваться может вся страница, за исключением баннера. + Используя функцию insert для баннера, вы можете сохранять + этот элемент динамичным, внутри кэшированой странички. Смотрите + документацию по insert для + получения подробностей и примеров. - You can clear all the cache files with the clear_all_cache() function, or - individual cache files (or groups) with the clear_cache() function. + Очистить все файлы кэша можно при помощи функции + clear_all_cache(), а + конкретный файл кэша (или группу) - вызвав + clear_cache() функцию. - - clearing the cache - + + Очистка кэша + +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'); - +$smarty->display('index.tpl'); +]]> + + \ No newline at end of file +-->