/**
 * Обёртка, кэширующая результаты _getIblocks() в глобальный массив $arIb
 */
function getIblocks()
{
    global $arIb;
    $obCache = \Bitrix\Main\Data\Cache::createInstance();
    $cacheTime = 86400;
    $cacheId = md5('s1');
    $cachePath = "iblocks";
    if ($obCache->initCache($cacheTime, $cacheId, $cachePath)) {
        $vars = $obCache->getVars();
        $arIb = $vars["arIb"];
    } elseif ($obCache->startDataCache()) {
        $arIb = _getIblocks();
        $obCache->endDataCache(array("arIb" => $arIb));
    }
}
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = $input->getOption('dir');
     $tag = $input->getOption('tag');
     $cache = Cache::createInstance();
     if (empty($dir) && empty($tag)) {
         Application::getInstance()->getManagedCache()->cleanAll();
         $cache->cleanDir();
         $cache->cleanDir(false, 'stack_cache');
         StaticHtmlCache::getInstance()->deleteAll();
         if (Cache::clearCache(true)) {
             $output->writeln('<info>All Bitrix cache was deleted</info>');
         } else {
             $output->writeln('<error>Error deleting Bitrix cache</error>');
         }
     }
     if ($dir) {
         $cache->cleanDir($dir);
         $output->writeln('<info>Bitrix cache by "/' . BX_ROOT . '/cache/' . $dir . '" dir was deleted</info>');
     }
     if ($tag) {
         Application::getInstance()->getTaggedCache()->clearByTag($tag);
         $output->writeln('<info>Bitrix cache by tag "' . $tag . '" was deleted</info>');
     }
 }
function getPropertiesEx($arParams)
{
    $obCache = \Bitrix\Main\Data\Cache::createInstance();
    $cacheTime = 86400;
    $cacheId = md5($arParams);
    $cachePath = "properties";
    $arProperties = array();
    if ($obCache->initCache($cacheTime, $cacheId, $cachePath)) {
        $vars = $obCache->getVars();
        $arProperties = $vars["arProperties"];
    } elseif ($obCache->startDataCache()) {
        $arProperties = _getPropertiesEx($arParams);
        $obCache->endDataCache(array("arProperties" => $arProperties));
    }
    return $arProperties;
}
Beispiel #4
0
 public function onUserSetLastActivityDate(\Bitrix\Main\Event $event)
 {
     $users = $event->getParameter(0);
     foreach ($users as $userId) {
         $cache = \Bitrix\Main\Data\Cache::createInstance();
         if ($cache->startDataCache(60, $userId, '/im/status')) {
             $mapper = \Bitrix\Replica\Mapper::getInstance();
             $map = $mapper->getByPrimaryValue("b_im_status.USER_ID", false, $userId);
             if ($map) {
                 $guid = \Bitrix\Replica\Client\User::getLocalUserGuid($userId);
                 if ($guid && $map[$guid]) {
                     $event = array("operation" => "im_status_update", "guid" => $guid);
                     \Bitrix\Replica\Log\Client::getInstance()->write($map[$guid], $event);
                 }
             }
             $cache->endDataCache(true);
         }
     }
 }
Beispiel #5
0
 protected function getUserGroupWithStorage()
 {
     if (!\CBXFeatures::isFeatureEnabled("Workgroups")) {
         return array();
     }
     if (!Loader::includeModule('socialnetwork')) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $currentPossibleUserGroups = $currentUserGroups = array();
     $cache = Cache::createInstance();
     $cacheTtl = defined('BX_COMP_MANAGED_CACHE') ? 3153600 : 3600 * 4;
     $cachePath = "/disk/uf/{$userId}";
     if ($cache->initCache($cacheTtl, 'group_storage_list_' . SITE_ID . '_' . $userId, $cachePath)) {
         list($currentUserGroups) = $cache->getVars();
     } else {
         $cache->startDataCache();
         $taggedCache = Application::getInstance()->getTaggedCache();
         $taggedCache->startTagCache($cachePath);
         $diskSecurityContext = new DiskSecurityContext($userId);
         $storages = Storage::getReadableList($diskSecurityContext, array('filter' => array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className())));
         foreach ($storages as $storage) {
             $currentPossibleUserGroups[$storage->getEntityId()] = $storage;
         }
         unset($storage);
         $query = \CSocNetUserToGroup::getList(array('GROUP_NAME' => 'ASC'), array('USER_ID' => $userId, 'GROUP_ID' => array_keys($currentPossibleUserGroups)), false, false, array('GROUP_ID', 'GROUP_NAME', 'GROUP_ACTIVE', 'GROUP_CLOSED', 'ROLE'));
         while ($row = $query->getNext()) {
             if ($row['GROUP_ACTIVE'] == 'Y' && $row['GROUP_CLOSED'] == 'N' && $row['ROLE'] != SONET_ROLES_BAN && $row['ROLE'] != SONET_ROLES_REQUEST && isset($currentPossibleUserGroups[$row['GROUP_ID']])) {
                 $taggedCache->registerTag("sonet_features_G_{$row['GROUP_ID']}");
                 $taggedCache->registerTag("sonet_group_{$row['GROUP_ID']}");
                 $currentUserGroups[$row['GROUP_ID']] = array('STORAGE' => $currentPossibleUserGroups[$row['GROUP_ID']], 'NAME' => $row['GROUP_NAME']);
             }
         }
         $taggedCache->registerTag("sonet_user2group_U{$userId}");
         $taggedCache->endTagCache();
         $cache->endDataCache(array($currentUserGroups));
     }
     return $currentUserGroups;
 }
Beispiel #6
0
 public function __construct()
 {
     $this->cache = \Bitrix\Main\Data\Cache::createInstance();
 }
Beispiel #7
0
 /**
  * Returns new instance of the Cache object.
  *
  * @return Data\Cache
  */
 public function getCache()
 {
     return \Bitrix\Main\Data\Cache::createInstance();
 }
Beispiel #8
0
 /**
  * Returns items from cache. If cache expired will be executed request to DB (method $this->getItems()).
  *
  * @param array $filter Parameters for filter.
  * @param string $shard Shard of the cache.
  *
  * @return mixed
  *
  * @throws ValueNotFoundException Value was not found.
  * @throws \InvalidArgumentException Invalid type on filter.
  */
 protected function getFromCache($filter = [], $shard = null)
 {
     $filter = $this->prepareFilter($filter);
     $cache = Cache::createInstance();
     if ($cache->initCache(static::getCacheTime(), null, static::getCacheDir() . '/' . $shard)) {
         $items = $cache->getVars();
     } else {
         $cache->startDataCache();
         Application::getInstance()->getTaggedCache()->startTagCache(static::getCacheDir() . '/' . $shard);
         $items = $this->getItems($shard);
         if (!empty($items)) {
             Application::getInstance()->getTaggedCache()->endTagCache();
             $cache->endDataCache($items);
         } else {
             $cache->abortDataCache();
         }
     }
     try {
         return $this->getValue($items, $filter, $shard);
     } catch (ValueNotFoundException $e) {
         if ($this->silenceMode) {
             return null;
         }
         throw $e;
     }
 }
Beispiel #9
0
 /**
  * Function starts the caching block of the component execution.
  *
  * @param int|bool $cacheTime
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return string
  *
  */
 public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
         return true;
     }
     if ($cacheTime === false) {
         $cacheTime = intval($this->arParams["CACHE_TIME"]);
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $this->__cache = \Bitrix\Main\Data\Cache::createInstance();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted()) {
             $CACHE_MANAGER->startTagCache($this->__cachePath);
         }
         return true;
     } else {
         $arCache = $this->__cache->GetVars();
         $this->arResult = $arCache["arResult"];
         if (array_key_exists("templateCachedData", $arCache)) {
             $templateCachedData =& $arCache["templateCachedData"];
             if ($templateCachedData && is_array($templateCachedData)) {
                 if (array_key_exists("additionalCSS", $templateCachedData) && strlen($templateCachedData["additionalCSS"]) > 0) {
                     $APPLICATION->SetAdditionalCSS($templateCachedData["additionalCSS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildCSS($templateCachedData["additionalCSS"]);
                     }
                 }
                 if (array_key_exists("additionalJS", $templateCachedData) && strlen($templateCachedData["additionalJS"]) > 0) {
                     $APPLICATION->AddHeadScript($templateCachedData["additionalJS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildJS($templateCachedData["additionalJS"]);
                     }
                 }
                 if (array_key_exists("frames", $templateCachedData) && is_array($templateCachedData["frames"])) {
                     foreach ($templateCachedData["frames"] as $frameState) {
                         \Bitrix\Main\Page\FrameHelper::applyCachedData($frameState);
                     }
                 }
                 if (array_key_exists("frameMode", $templateCachedData) && $templateCachedData["frameMode"] === false) {
                     $context = isset($templateCachedData["frameModeCtx"]) ? "(from component cache) " . $templateCachedData["frameModeCtx"] : $this->__name . " - a cached template set frameMode=false";
                     \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($context);
                 }
                 if (isset($templateCachedData["externalCss"])) {
                     foreach ($templateCachedData["externalCss"] as $cssPath) {
                         $APPLICATION->SetAdditionalCSS($cssPath);
                         //Check if parent component exists and plug css it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildCSS($cssPath);
                         }
                     }
                 }
                 if (isset($templateCachedData["externalJs"])) {
                     foreach ($templateCachedData["externalJs"] as $jsPath) {
                         $APPLICATION->AddHeadScript($jsPath);
                         //Check if parent component exists and plug js it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildJS($jsPath);
                         }
                     }
                 }
             }
             if ($templateCachedData["__editButtons"]) {
                 foreach ($templateCachedData["__editButtons"] as $button) {
                     if ($button[0] == 'AddEditAction') {
                         $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
                     } else {
                         $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
                     }
                 }
             }
             if ($templateCachedData["__view"]) {
                 foreach ($templateCachedData["__view"] as $view_id => $target) {
                     foreach ($target as $view_content) {
                         $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
                     }
                 }
             }
             if (array_key_exists("__NavNum", $templateCachedData)) {
                 $GLOBALS["NavNum"] += $templateCachedData["__NavNum"];
             }
             if (array_key_exists("__children_css", $templateCachedData)) {
                 foreach ($templateCachedData["__children_css"] as $css_url) {
                     $APPLICATION->setAdditionalCSS($css_url);
                 }
             }
             if (array_key_exists("__children_js", $templateCachedData)) {
                 foreach ($templateCachedData["__children_js"] as $js_url) {
                     $APPLICATION->addHeadScript($js_url);
                 }
             }
             if (array_key_exists("__children_epilogs", $templateCachedData)) {
                 foreach ($templateCachedData["__children_epilogs"] as $component_epilog) {
                     $this->includeComponentEpilog($component_epilog);
                 }
             }
             if (array_key_exists("component_epilog", $templateCachedData)) {
                 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
             }
         }
         return false;
     }
 }
Beispiel #10
0
 /**
  * Returns new instance of the Cache object.
  *
  * @return Data\Cache
  */
 public static function getCache()
 {
     return Data\Cache::createInstance();
 }
Beispiel #11
0
 private function loadFormattedFolderTreeAndBreadcrumbs($returnTree = false)
 {
     $cache = Data\Cache::createInstance();
     if ($cache->initCache(15768000, 'storage_tr_' . $this->storage->getId(), 'disk')) {
         list($formattedFolders, $this->cacheBreadcrumbs) = $cache->getVars();
     } else {
         $querySharedFolders = \Bitrix\Disk\Sharing::getList(array('filter' => array('FROM_ENTITY' => Sharing::CODE_USER . $this->getUser()->getId(), '!TO_ENTITY' => Sharing::CODE_USER . $this->getUser()->getId())));
         $sharedFolders = array();
         while ($sharedFolder = $querySharedFolders->fetch()) {
             $sharedFolders[$sharedFolder['REAL_OBJECT_ID']] = $sharedFolder['REAL_OBJECT_ID'];
         }
         $formattedFolders = array();
         foreach ($this->walkAndBuildTree($this->storage->getRootObject()) as $folder) {
             /** @var Folder $folder */
             $formattedFolders[] = $this->formatFolderToResponse($folder, isset($sharedFolders[$folder->getId()]));
         }
         unset($folder);
         $cache->startDataCache();
         $cache->endDataCache(array($formattedFolders, $this->cacheBreadcrumbs));
     }
     return $returnTree ? $formattedFolders : null;
 }
Beispiel #12
0
    }
}
######################################################
######################################################
######################################################
if (!isset($arParams['CACHE_TIME'])) {
    $arParams['CACHE_TIME'] = 999999;
}
if (!isset($arParams['CACHE_TYPE'])) {
    $arParams['CACHE_TYPE'] = 'A';
}
// obtain cached data
$cacheNeeded = intval($arParams['CACHE_TIME']) > 0 && $arParams['CACHE_TYPE'] != 'N' && \Bitrix\Main\Config\Option::get("main", "component_cache_on", "Y") == "Y";
$cachedData = array();
if ($cacheNeeded) {
    $currentCache = \Bitrix\Main\Data\Cache::createInstance();
    $cacheDir = '/sale/location/legacy/component/sal';
    if ($currentCache->startDataCache(intval($arParams['CACHE_TIME']), implode('|', array_merge($arParams, array(SITE_ID, LANGUAGE_ID))), $cacheDir)) {
        global $CACHE_MANAGER;
        $CACHE_MANAGER->StartTagCache($cacheDir);
        try {
            $cachedData['ZONE_IDS'] = SalesZone::getSelectedIds($arParams["SITE_ID"]);
            $cachedData['DEFAULT_LOCS'] = array();
            $res = CSaleLocation::GetList(array("SORT" => "ASC", "COUNTRY_NAME_LANG" => "ASC", "CITY_NAME_LANG" => "ASC"), array("LOC_DEFAULT" => "Y", "LID" => LANGUAGE_ID), false, false, array("*"));
            while ($item = $res->fetch()) {
                $cachedData['DEFAULT_LOCS'][] = $item;
            }
        } catch (Exception $e) {
            if ($cacheNeeded) {
                $CACHE_MANAGER->AbortTagCache();
                $currentCache->abortDataCache();
Beispiel #13
0
 /**
  * Function starts the caching block of the component execution.
  *
  * @param int|bool $cacheTime
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return string
  *
  */
 public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
         return true;
     }
     if ($cacheTime === false) {
         $cacheTime = intval($this->arParams["CACHE_TIME"]);
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $this->__cache = \Bitrix\Main\Data\Cache::createInstance();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted()) {
             $CACHE_MANAGER->startTagCache($this->__cachePath);
         }
         return true;
     } else {
         $arCache = $this->__cache->GetVars();
         $this->arResult = $arCache["arResult"];
         if (array_key_exists("templateCachedData", $arCache)) {
             $templateCachedData =& $arCache["templateCachedData"];
             CBitrixComponentTemplate::applyCachedData($templateCachedData);
             if ($templateCachedData["__editButtons"]) {
                 foreach ($templateCachedData["__editButtons"] as $button) {
                     if ($button[0] == 'AddEditAction') {
                         $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
                     } else {
                         $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
                     }
                 }
             }
             if ($templateCachedData["__view"]) {
                 foreach ($templateCachedData["__view"] as $view_id => $target) {
                     foreach ($target as $view_content) {
                         $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
                     }
                 }
             }
             if (array_key_exists("__NavNum", $templateCachedData)) {
                 $GLOBALS["NavNum"] += $templateCachedData["__NavNum"];
             }
             if (array_key_exists("__children_css", $templateCachedData)) {
                 foreach ($templateCachedData["__children_css"] as $css_url) {
                     $APPLICATION->setAdditionalCSS($css_url);
                 }
             }
             if (array_key_exists("__children_js", $templateCachedData)) {
                 foreach ($templateCachedData["__children_js"] as $js_url) {
                     $APPLICATION->addHeadScript($js_url);
                 }
             }
             if (array_key_exists("__children_epilogs", $templateCachedData)) {
                 foreach ($templateCachedData["__children_epilogs"] as $component_epilog) {
                     $this->includeComponentEpilog($component_epilog);
                 }
             }
             if (array_key_exists("component_epilog", $templateCachedData)) {
                 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
             }
         }
         return false;
     }
 }
Beispiel #14
0
 public function clearByTag($tag)
 {
     $con = Main\Application::getConnection();
     $sqlHelper = $con->getSqlHelper();
     if ($tag === true) {
         $sqlWhere = " WHERE TAG <> '*'";
     } else {
         $sqlWhere = "  WHERE TAG = '" . $sqlHelper->forSql($tag) . "'";
     }
     $arDirs = array();
     $rs = $con->query("SELECT * FROM b_cache_tag" . $sqlWhere);
     while ($ar = $rs->fetch()) {
         $arDirs[$ar["RELATIVE_PATH"]] = $ar;
     }
     $con->queryExecute("DELETE FROM b_cache_tag" . $sqlWhere);
     $cache = Cache::createInstance();
     $managedCache = Main\Application::getInstance()->getManagedCache();
     foreach ($arDirs as $path => $ar) {
         $con->queryExecute("\n\t\t\t\tDELETE FROM b_cache_tag\n\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($ar["SITE_ID"]) . "'\n\t\t\t\tAND CACHE_SALT = '" . $sqlHelper->forSql($ar["CACHE_SALT"]) . "'\n\t\t\t\tAND RELATIVE_PATH = '" . $sqlHelper->forSql($ar["RELATIVE_PATH"]) . "'\n\t\t\t");
         if (preg_match("/^managed:(.+)\$/", $path, $match)) {
             $managedCache->cleanDir($match[1]);
         } else {
             $cache->cleanDir($path);
         }
         unset($this->dbCacheTags[$path]);
     }
 }
Beispiel #15
0
 /**
  * Cleans cache with folders tree.
  *
  * @internal
  * @deprecated
  * @param array $storageIds List of storage id.
  * @return void
  */
 public function cleanCacheTreeBitrixDisk(array $storageIds)
 {
     $cache = Cache::createInstance();
     foreach ($storageIds as $id) {
         $cache->clean('storage_tr_' . $id, 'disk');
     }
     unset($id);
 }
Beispiel #16
0
 public static function finalize()
 {
     $cacheManager = Main\Application::getInstance()->getManagedCache();
     $cache = Cache::createInstance();
     foreach ($cacheManager->cache as $uniqueId => $val) {
         if (array_key_exists($uniqueId, $cacheManager->vars)) {
             $cache->startDataCache($cacheManager->ttl[$uniqueId], $uniqueId, $cacheManager->cachePath[$uniqueId], $cacheManager->vars[$uniqueId], "managed_cache");
             $cache->endDataCache();
         }
     }
 }
Beispiel #17
0
	/**
	 * Function perform start of cache process, if needed
	 * @param mixed[]|string $cacheId An optional addition for cache key
	 * @return boolean True, if cache content needs to be generated, false if cache is valid and can be read
	 */
	final protected function startCache($cacheId = array())
	{
		if(!$this->getCacheNeed())
			return true;

		$this->currentCache = Data\Cache::createInstance();

		return $this->currentCache->startDataCache(intval($this->arParams['CACHE_TIME']), $this->getCacheKey($cacheId), static::COMPONENT_CACHE_DIR);
	}
Beispiel #18
0
 public function Save()
 {
     if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) {
         return;
     }
     global $DB;
     if (!$this->cleanSet || !$this->cleanGet && count($this->values) >= $this->len) {
         $objCache = \Bitrix\Main\Data\Cache::createInstance();
         //Force cache rewrite
         $saveClearState = $objCache->setClearCache(true);
         if ($objCache->StartDataCache($this->ttl, $this->entity, $DB->type . "/" . $this->entity, $this->values, "stack_cache")) {
             $objCache->EndDataCache();
         }
         $objCache->setClearCache($saveClearState);
         $this->cleanGet = true;
         $this->cleanSet = true;
     }
 }
Beispiel #19
0
/**
 * Обёртка, кэширующая результаты _getListEx()
 *
 * Возможные параметры $arOptions:
 * - *iblock_id* - ID или символьный код инфоблока
 * - *filter* - Параметры фильтра
 * - *sort* - Параметры сортировки
 * - *select* - Поля для выборки
 * - *get_sections* - *true*, если нужно выбрать секции, а не элементы
 * - *id_key* - *true*, если ключи результирующего массива
 *              должны принять значения ID элемента:<br>
 *              <code>array(ID1 => array(...), ID2 => array(...))</code><br>
 *              Если параметр равен *false*, массив будет неассоциативным:<br>
 *              <code>array(array(...), array(...))</code>
 * - *is_sub_query* - Если *true*, результат выборки будет оформлен для фильтрации в другом _getListEx()
 * - *cache_time* - Время хранения кэша
 * - *nav* — Параметры для постраничной навигации, формируются, как в стандартном GetList()
 *           https://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockelement/getlist.php
 * 
 * @example getlistex.php Выбор всех компаний, у которых есть офис в Ярославле. Пример вложенных getListEx
 * @param  array $arOptions Параметры выборки
 * @return array            Массив с результатами выборки
 */
function getListEx($arOptions)
{
    $iblockId = iblock($arOptions['iblock_id']);
    if ($iblockId === false) {
        return false;
    }
    $obCache = \Bitrix\Main\Data\Cache::createInstance();
    $cacheTime = intval($arOptions['cache_time']) > 0 ? intval($arOptions['cache_time']) : 3600;
    $cacheId = md5(serialize($arOptions));
    $cachePath = '/lists_ex/' . $iblockId . '/';
    $arElements = array();
    if ($obCache->initCache($cacheTime, $cacheId, $cachePath)) {
        $vars = $obCache->getVars();
        $arElements = $vars['arElements'];
    } elseif ($obCache->startDataCache()) {
        global $CACHE_MANAGER;
        $CACHE_MANAGER->StartTagCache($cachePath);
        $CACHE_MANAGER->RegisterTag('iblock_id_' . $iblockId);
        $arElements = _getListEx($arOptions);
        foreach ($arElements as $arElement) {
            if (isset($arElement["ID"])) {
                $CACHE_MANAGER->RegisterTag("element_" . $arElement["ID"]);
            }
            if (!is_array($arElement) && intval($arElement) > 0) {
                $CACHE_MANAGER->RegisterTag("element_" . intval($arElement));
            }
        }
        $CACHE_MANAGER->EndTagCache();
        $obCache->endDataCache(array('arElements' => $arElements));
    }
    return $arElements;
}
Beispiel #20
0
 public function save()
 {
     Config\Option::set('security', $this->optionPrefix . 'hosts', $this->hosts, '');
     Config\Option::set('security', $this->optionPrefix . 'action', $this->action, '');
     Config\Option::set('security', $this->optionPrefix . 'action_options', serialize($this->actionOptions), '');
     Config\Option::set('security', $this->optionPrefix . 'logging', $this->isLogNeeded, '');
     if (!is_null($this->isActive)) {
         if ($this->isActive) {
             EventManager::getInstance()->registerEventHandler('main', 'OnPageStart', 'security', get_class($this), 'onPageStart');
         } else {
             EventManager::getInstance()->unRegisterEventHandler('main', 'OnPageStart', 'security', get_class($this), 'onPageStart');
         }
     }
     Data\Cache::createInstance()->clean($this->cacheId);
 }
Beispiel #21
0
 /**
  * Function perform start of cache process, if needed
  * @param mixed[]|string $cacheId An optional addition for cache key
  * @return boolean True, if cache content needs to be generated, false if cache is valid and can be read
  */
 protected final function startCache($cacheId = array())
 {
     if (!$this->getCacheNeed()) {
         return true;
     }
     $this->currentCache = Data\Cache::createInstance();
     return $this->currentCache->startDataCache(intval($this->arParams['CACHE_TIME']), $this->getCacheKey($cacheId));
 }
Beispiel #22
0
 /**
  * callbackFunction
  * @param bool $refresh_cache
  * @internal param bool $bRefreshCache
  */
 private function callbackFunction($refresh_cache = false)
 {
     $new = $this->cacheId;
     if (isset($new[$this->sUrlKey])) {
         unset($new[$this->sUrlKey]);
         unset($new['sessid']);
     }
     $this->cacheId = $this->sComponentId;
     $return = [];
     $cache = Cache::createInstance();
     if (!$refresh_cache && $cache->initCache($this->getCacheTime(), $this->cacheId, $this->cachePath)) {
         $return = $cache->getVars();
     } elseif ($cache->startDataCache($this->getCacheTime(), $this->cacheId, $this->cachePath)) {
         if (isset($this->arParams['CALL_FUNCTION'])) {
             if (is_callable($this->arParams['CALL_FUNCTION'])) {
                 ob_start();
                 $this->arParams['CALL_FUNCTION']();
                 $return = ob_get_contents();
                 ob_end_clean();
             }
         }
         if (!$return) {
             $cache->abortDataCache();
         }
         $cache->endDataCache($return);
     }
     print $return;
 }