コード例 #1
0
ファイル: cache.php プロジェクト: ASDAFF/open_bx
 public function __construct()
 {
     $this->cache = \Freetrix\Main\Data\Cache::createInstance();
 }
コード例 #2
0
ファイル: taggedcache.php プロジェクト: ASDAFF/open_bx
 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]);
     }
 }
コード例 #3
0
ファイル: managedcache.php プロジェクト: ASDAFF/open_bx
 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();
         }
     }
 }
コード例 #4
0
ファイル: component.php プロジェクト: ASDAFF/open_bx
 /**
  * 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 = \Freetrix\Main\Data\Cache::createInstance();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("FX_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) {
                         \Freetrix\Main\Page\FrameHelper::applyCachedData($frameState);
                     }
                 }
             }
             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;
     }
 }