Skip to content

Instantly share code, notes, and snippets.

@SerjRamone
Created July 9, 2013 05:54
Show Gist options
  • Save SerjRamone/5955015 to your computer and use it in GitHub Desktop.
Save SerjRamone/5955015 to your computer and use it in GitHub Desktop.
Сache Dependencies (тегированный кеш)
<?
$cache_id = md5(serialize($arParams));
$cache_dir = "/tagged_getlist";
$obCache = new CPHPCache;
if($obCache->InitCache(36000, $cache_id, $cache_dir)) {
$arElements = $obCache->GetVars();
}
elseif(CModule::IncludeModule("iblock") && $obCache->StartDataCache()) {
$arElements = array();
$rsElements = CIBlockElement::GetList($arParams["order"], $arParams["filter"]);
global $CACHE_MANAGER;
$CACHE_MANAGER->StartTagCache($cache_dir);
while($arElement = $rsElements->Fetch()) {
$CACHE_MANAGER->RegisterTag("iblock_id_".$arElement["ID"]);
$arElements[] = $arElement;
}
$CACHE_MANAGER->RegisterTag("iblock_id_new");
$CACHE_MANAGER->EndTagCache();
$obCache->EndDataCache($arIBlocks);
} else {
$arElements = array();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment