Кеширование в 1С-Битрикс D7
public static function getService(){
$obCache = \Bitrix\Main\Data\Cache::createInstance();
$cache_time = "86400";
$cache_id = "service.".self::$profileId;
if( $obCache->initCache($cache_time,$cache_id,"/mlife/comments/service/") )
{
$vars = $obCache->GetVars();
}elseif( $obCache->startDataCache()){
$res = \Mlife\Comments\ServicesTable::getById(self::$profileId);
if($vars = $res->Fetch()){
$obCache->endDataCache($vars);
}else{
$obCache->abortDataCache();
}
}
return $vars;
}
$obCache = \Bitrix\Main\Data\Cache::createInstance();
$cache_id = "service.".$primary["ID"];
$obCache->clean($cache_id, "/mlife/comments/service/");
Источник: https://dev.1c-bitrix.ru/community/webdev/user/87386/blog/11342/