Spec-Zone.ru › Phalcon 2

Класс Phalcon\Cache\Frontend\Output

реализует Phalcon\Cache\FrontendInterface

Разрешает кеширование фрагментов вывода, полученных с помощью функций ob_*

//Create an Output frontend. Cache the files for 2 days
 $frontCache = new Phalcon\Cache\Frontend\Output(array(
   "lifetime" => 172800
 ));

 // Create the component that will cache from the "Output" to a "File" backend
 // Set the cache file directory - it's important to keep the "/" at the end of
 // the value for the folder
 $cache = new Phalcon\Cache\Backend\File($frontCache, array(
     "cacheDir" => "../app/cache/"
 ));

 // Get/Set the cache file to ../app/cache/my-cache.html
 $content = $cache->start("my-cache.html");

 // If $content is null then the content will be generated for the cache
 if ($content === null) {

     //Print date and time
     echo date("r");

     //Generate a link to the sign-up action
     echo Phalcon\Tag::linkTo(
         array(
             "user/signup",
             "Sign Up",
             "class" => "signup-button"
         )
     );

     // Store the output into the cache file
     $cache->save();

 } else {

     // Echo the cached output
     echo $content;
 }

Методы

public __construct ([массив $frontendOptions])

Конструктор Phalcon\Cache\Frontend\Output

public целое getLifetime ()

Возвращает срок действия кеша

public логическое isBuffering ()

Проверяет, буферизует ли фронтенд вывод

public start ()

Инициализирует фронтенд вывода

public строка getContent ()

Возвращает кэшированное содержимое вывода

public stop ()

Завершает работу фронтенда вывода

public смешанный beforeStore (смешанный $data)

Подготавливает данные для хранения

public смешанный afterRetrieve (смешанный $data)

Подготавливает данные для получения пользователем

© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Cache_Frontend_Output.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API