Класс Phalcon\Cache\Frontend\Igbinary
extends класс Phalcon\Cache\Frontend\Data
implements Phalcon\Cache\FrontendInterface
Позволяет кэшировать данные PHP в сериализованном виде с использованием расширения igbinary
// Cache the files for 2 days using Igbinary frontend
$frontCache = new Phalcon\Cache\Frontend\Igbinary(array(
"lifetime" => 172800
));
// Create the component that will cache "Igbinary" to a "File" backend
// Set the cache file directory - important to keep the "/" at the end of
// of the value for the folder
$cache = new Phalcon\Cache\Backend\File($frontCache, array(
"cacheDir" => "../app/cache/"
));
// Try to get cached records
$cacheKey = 'robots_order_id.cache';
$robots = $cache->get($cacheKey);
if ($robots === null) {
// $robots is null due to cache expiration or data do not exist
// Make the database call and populate the variable
$robots = Robots::find(array("order" => "id"));
// Store it in the cache
$cache->save($cacheKey, $robots);
}
// Use $robots :)
foreach ($robots as $robot) {
echo $robot->name, "\n";
}
Методы
public string beforeStore (mixed $data)
Сериализует данные перед сохранением
public mixed afterRetrieve (mixed $data)
Десериализует данные после извлечения
public __construct ([array $frontendOptions]) унаследовано от Phalcon\Cache\Frontend\Data
Конструктор Phalcon\Cache\Frontend\Data
public int getLifetime () унаследовано от Phalcon\Cache\Frontend\Data
Возвращает срок хранения кэша
public boolean isBuffering () унаследовано от Phalcon\Cache\Frontend\Data
Проверяет, буферизует ли фронтенд вывод
public start () унаследовано от Phalcon\Cache\Frontend\Data
Инициализирует фронтенд вывода. На самом деле, ничего не делает
public string getContent () унаследовано от Phalcon\Cache\Frontend\Data
Возвращает кэшированный вывод
public stop () унаследовано от Phalcon\Cache\Frontend\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_Igbinary.html