Skip to content

Instantly share code, notes, and snippets.

@vozhukh
Last active December 13, 2016 13:07
Show Gist options
  • Save vozhukh/86fd00f07957cda607199448b5814ec0 to your computer and use it in GitHub Desktop.
Save vozhukh/86fd00f07957cda607199448b5814ec0 to your computer and use it in GitHub Desktop.
Також в D7 з'явився зручний доступ до керованого кешу, об'єкт для управління кешем можна отримати з об'єкта програми:
<?php
$cache = \Bitrix\Main\Application::getInstance()->getManagedCache();
?>
$cache є об'єктом \Bitrix\Main\Data\ManagedCache.
Приклад використання:
<?php
if ($cache->read($cacheTtl, $cacheId)) {
$vars = $cache->get($cacheId); // достаем переменные из кеша
} else {
// некоторые действия...
$cache->set($cacheId, array("key" => $value)); // записываем в кеш
}
?>
Для примусового очищення кеша по ключу використовуємо:
<?php
$cache->clean($cacheId);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment