Last active
December 13, 2016 13:07
-
-
Save vozhukh/86fd00f07957cda607199448b5814ec0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Також в 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