当前位置: 首页>>代码示例>>PHP>>正文


PHP CPHPCache::InitCache方法代码示例

本文整理汇总了PHP中CPHPCache::InitCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CPHPCache::InitCache方法的具体用法?PHP CPHPCache::InitCache怎么用?PHP CPHPCache::InitCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPHPCache的用法示例。


在下文中一共展示了CPHPCache::InitCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPropertyFieldSections

 public static function getPropertyFieldSections($linkIblockId)
 {
     $linkIblockId = (int) $linkIblockId;
     if ($linkIblockId <= 0) {
         return false;
     }
     $ttl = 10000;
     $cache_id = 'catalog_store_sections';
     $cache_dir = '/bx/catalog_store_sections';
     $obCache = new CPHPCache();
     if ($obCache->InitCache($ttl, $cache_id, $cache_dir)) {
         $res = $obCache->GetVars();
     } else {
         $res = array();
     }
     if (!isset($res[$linkIblockId])) {
         $res[$linkIblockId] = array();
         $sectionsIterator = Iblock\SectionTable::getList(array('select' => array('*'), 'filter' => array('=IBLOCK_ID' => $linkIblockId), 'order' => array('LEFT_MARGIN' => 'ASC')));
         while ($section = $sectionsIterator->fetch()) {
             $res[$linkIblockId][] = $section;
         }
         unset($section, $sectionsIterator);
         if ($obCache->StartDataCache()) {
             $obCache->EndDataCache($res);
         }
     }
     return $res[$linkIblockId];
 }
开发者ID:Satariall,项目名称:izurit,代码行数:28,代码来源:class.php

示例2: isMandatoryUserFieldExists

 /**
  * @return bool true if some mandatory UF exists for TASKS
  */
 public static function isMandatoryUserFieldExists()
 {
     /** @var $CACHE_MANAGER CCacheManager */
     global $CACHE_MANAGER;
     $isFieldExists = null;
     // unknown yet
     $obCache = new CPHPCache();
     $lifeTime = CTasksTools::CACHE_TTL_UNLIM;
     $cacheID = md5('uftasks');
     $cacheDir = "/tasks/ufs";
     if (defined('BX_COMP_MANAGED_CACHE') && $obCache->InitCache($lifeTime, $cacheID, $cacheDir)) {
         $data = $obCache->GetVars();
         $isFieldExists = $data['isFieldExists'];
     } else {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $rsUserType = CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'TASKS_TASK', 'MANDATORY' => 'Y'));
         if ($rsUserType->fetch()) {
             $isFieldExists = true;
         } else {
             $isFieldExists = false;
         }
         if (defined('BX_COMP_MANAGED_CACHE') && $obCache->StartDataCache()) {
             $CACHE_MANAGER->StartTagCache($cacheDir);
             $CACHE_MANAGER->RegisterTag('tasks_user_fields');
             $CACHE_MANAGER->EndTagCache();
             $data = array('isFieldExists' => $isFieldExists);
             $obCache->EndDataCache($data);
         }
     }
     return $isFieldExists;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:34,代码来源:taskrarelytools.php

示例3: getJobName

 public static function getJobName($id)
 {
     if (empty($id)) {
         return false;
     }
     $result = false;
     $obCache = new CPHPCache();
     $dir = '/companies/names';
     if ($obCache->InitCache(9999999999, md5($id), $dir)) {
         $result = $obCache->GetVars();
     } elseif ($obCache->StartDataCache() && \Bitrix\Main\Loader::includeModule('iblock')) {
         if ($result = CIBlockElement::GetByID($id)->Fetch()) {
             if (defined('BX_COMP_MANAGED_CACHE')) {
                 $GLOBALS['CACHE_MANAGER']->StartTagCache($dir);
                 $GLOBALS['CACHE_MANAGER']->RegisterTag('iblock_id_' . $result['IBLOCK_ID']);
             }
             $result = $result['NAME'];
             if (defined('BX_COMP_MANAGED_CACHE')) {
                 $GLOBALS['CACHE_MANAGER']->EndTagCache();
             }
         }
         $obCache->EndDataCache($result);
     }
     return $result;
 }
开发者ID:Tvaruga,项目名称:ae,代码行数:25,代码来源:CInc.php

示例4: loadConfig

 public function loadConfig()
 {
     //todo fix empty config caching
     $cache = new \CPHPCache();
     $cacheFile = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/" . $cache->GetPath(__CLASS__);
     // проверяем, обновлялся ли конфиг
     $cacheWritten = filemtime($cacheFile);
     $configWritten = filemtime($this->configFile);
     // устаревший кеш или неудачно начатый кеш перезаписываем
     if ($configWritten > $cacheWritten || !$cache->InitCache(self::TTL, __CLASS__, '/')) {
         $cache->Clean(__CLASS__, '/');
         try {
             parent::loadConfig();
             if ($cache->StartDataCache(self::TTL, __CLASS__, '/')) {
                 $cache->EndDataCache(array('config' => $this->config));
             } else {
                 _log('Caching failed', 'widgets');
             }
         } catch (Exception $e) {
             _log('loading config error: ' . $e->getMessage(), 'widgets');
         }
     } else {
         $vars = $cache->GetVars();
         $this->config = $vars['config'];
     }
 }
开发者ID:ASDAFF,项目名称:bx-structure,代码行数:26,代码来源:BStructure.php

示例5: getPropertyFieldSections

 public static function getPropertyFieldSections($linkIblockId)
 {
     $linkIblockId = (int) $linkIblockId;
     if ($linkIblockId <= 0) {
         return false;
     }
     $ttl = 10000;
     $cache_id = 'catalog_store_sections';
     $cache_dir = '/bx/catalog_store_sections';
     $obCache = new CPHPCache();
     if ($obCache->InitCache($ttl, $cache_id, $cache_dir)) {
         $res = $obCache->GetVars();
     } else {
         $res = array();
     }
     if (!isset($res[$linkIblockId])) {
         $res[$linkIblockId] = array();
         $sections = \CIBlockSection::GetTreeList(array("IBLOCK_ID" => $linkIblockId));
         while ($row = $sections->Fetch()) {
             $res[$linkIblockId][] = $row;
         }
         if ($obCache->StartDataCache()) {
             $obCache->EndDataCache($res);
         }
     }
     return $res[$linkIblockId];
 }
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:27,代码来源:class.php

示例6: getListElements

function getListElements( $arSort = array(), $arFilter = array(), $arNav = array(), $arGroup = array(), $arSelect = array(), $cache_id = '' ) {
	
	$cache = new CPHPCache();
	$cache_time = 3600;
	$cache_id = 'service_calc_'.$cache_id.'_'.md5(array( $arSort,$arFilter, $arNav, $arGroup, $arSelect, $cache_id));
	$cache_path = '/bitrix/cache/';

	if ($cache_time > 0 && $cache->InitCache($cache_time, $cache_id, $cache_path))
	{
	   $res = $cache->GetVars();
	   if (is_array($res["dbElements"]) && (!empty($res["dbElements"]) ) )
		  $dbElements = $res["dbElements"];
	}
	if (empty($dbElements))
	{
	   $dbElements = CIBlockElement::GetList ( $arSort,$arFilter, $arNav, $arGroup, $arSelect);
	   
	   //////////// end cache /////////
	   if ($cache_time > 0)
	   {
			 $cache->StartDataCache ( $cache_time, $cache_id, $cache_path);
			 $cache->EndDataCache   ( array("dbElements" => $dbElements) );
	   }
	}
	return $dbElements;
}
开发者ID:raffiz,项目名称:my_home_tests,代码行数:26,代码来源:functions.php

示例7: sectionUFields

 public static function sectionUFields($primary)
 {
     if (!$primary) {
         throw new ArgumentException('Не указан идентификатор инфоблока');
     }
     $cache = new \CPHPCache();
     $path = self::createPath(__METHOD__);
     $cacheId = md5($primary . $path);
     if ($cache->InitCache(86400 * 2, $cacheId, $path)) {
         $uFields = $cache->GetVars();
     } else {
         if (!is_numeric($primary)) {
             $iblock = self::iblock($primary);
             if (!$iblock) {
                 $cache->AbortDataCache();
                 return null;
             }
             $primary = $iblock['ID'];
         }
         global $USER_FIELD_MANAGER;
         $uFields = $USER_FIELD_MANAGER->getUserFields("IBLOCK_{$primary}_SECTION");
         if ($cache->StartDataCache()) {
             $cache->EndDataCache($uFields);
         }
     }
     return $uFields;
 }
开发者ID:maximaster,项目名称:tools.orm,代码行数:27,代码来源:IblockStructure.php

示例8: addVariants

 public function addVariants(&$field, $params)
 {
     if (!$params["LINK_IBLOCK_ID"]) {
         return;
     }
     $cacheDir = KFilter::$config['CACHE_DIR'] . self::$cacheSubdir;
     $obCache = new CPHPCache();
     if ($obCache->InitCache(KFilter::$config['CACHE_TIME'], md5($params["LINK_IBLOCK_ID"] . __METHOD__), $cacheDir)) {
         $field['VARIANTS'] = $obCache->GetVars();
     } elseif ($obCache->StartDataCache()) {
         CModule::IncludeModule('iblock');
         global $CACHE_MANAGER;
         $CACHE_MANAGER->StartTagCache($cacheDir);
         $CACHE_MANAGER->RegisterTag("iblock_id_" . $params["LINK_IBLOCK_ID"]);
         $CACHE_MANAGER->EndTagCache();
         $rsSect = CIBlockSection::GetList(array('sort' => 'asc', 'name' => 'asc'), array('IBLOCK_ID' => $params["LINK_IBLOCK_ID"], 'ACTIVE' => 'Y'), false, array('ID', 'NAME'));
         while ($arSect = $rsSect->GetNext()) {
             $field['VARIANTS'][] = array('ID' => $arSect['ID'], 'NAME' => $arSect['NAME']);
         }
         $obCache->EndDataCache($field['VARIANTS']);
     }
     foreach ($field['VARIANTS'] as &$section) {
         if ($_REQUEST[$field['NAME']] == $section['ID']) {
             $section['SELECTED'] = 'Y';
             $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $params["LINK_IBLOCK_ID"], "SECTION_ID" => $section['ID']), false, false, array("ID", "IBLOCK_ID"));
             $arr = array();
             while ($el = $res->GetNext()) {
                 $arr[] = $el['ID'];
             }
             $this->filter['PROPERTY_' . $field['PROPERTY']] = $arr;
             break;
         }
     }
 }
开发者ID:ASDAFF,项目名称:bitrix-modules-advancedfilter,代码行数:34,代码来源:kfsectlinkelement.php

示例9: set

 /**
  * @param $name
  * @param $value
  * @param int $time
  */
 public function set($name, $value, $time = 3600)
 {
     $cache = new \CPHPCache();
     list($dir, $name) = $this->dirAndName($name);
     $cache->InitCache($time, $name, $dir);
     $cache->Clean($name, $dir);
     $cache->StartDataCache();
     $cache->EndDataCache(array('value' => $value));
 }
开发者ID:techart,项目名称:bitrix.tao,代码行数:14,代码来源:cache.php

示例10: getData

 public static function getData($SITE_ID = SITE_ID, $bFull = false)
 {
     global $USER, $CACHE_MANAGER;
     $obCache = new CPHPCache();
     $today = ConvertTimeStamp();
     $cache_dir = '/intranet/planner/' . $USER->GetID();
     $cache_id = 'intranet|planner|' . $USER->GetID() . '|' . $SITE_ID . '|' . intval($bFull) . '|' . $today . '|' . FORMAT_DATETIME . '|' . FORMAT_DATE . '|' . LANGUAGE_ID;
     $arData = null;
     if ($obCache->InitCache(self::CACHE_TTL, $cache_id, $cache_dir)) {
         $arData = $obCache->GetVars();
         if (is_array($arData['SCRIPTS'])) {
             foreach ($arData['SCRIPTS'] as $key => $script) {
                 if (is_array($script)) {
                     $arData['SCRIPTS'][$key] = self::JS_CORE_EXT_RANDOM_NAME . RandString(5);
                     CJSCore::RegisterExt($arData['SCRIPTS'][$key], $script);
                 }
             }
         }
     } else {
         // cache expired or there's no cache
         $obCache->StartDataCache();
         $arData = array('SCRIPTS' => array(), 'STYLES' => array(), 'DATA' => array());
         $CACHE_MANAGER->StartTagCache($cache_dir);
         $CACHE_MANAGER->RegisterTag(self::CACHE_TAG . $USER->GetID());
         $events = GetModuleEvents("intranet", "OnPlannerInit");
         while ($arEvent = $events->Fetch()) {
             $arEventData = ExecuteModuleEventEx($arEvent, array(array('SITE_ID' => SITE_ID, 'FULL' => $bFull)));
             if (is_array($arEventData)) {
                 if (is_array($arEventData['SCRIPTS'])) {
                     $arData['SCRIPTS'] = array_merge($arData['SCRIPTS'], $arEventData['SCRIPTS']);
                 }
                 if (is_array($arEventData['STYLES'])) {
                     $arData['STYLES'] = array_merge($arData['STYLES'], $arEventData['STYLES']);
                 }
                 if (is_array($arEventData['DATA'])) {
                     $arData['DATA'] = array_merge($arData['DATA'], $arEventData['DATA']);
                 }
             }
         }
         $arCacheData = $arData;
         if (is_array($arCacheData['SCRIPTS'])) {
             foreach ($arCacheData['SCRIPTS'] as $key => $script) {
                 if (CJSCore::IsExtRegistered($script)) {
                     $arCacheData['SCRIPTS'][$key] = CJSCore::getExtInfo($script);
                 }
             }
         }
         $CACHE_MANAGER->EndTagCache();
         $obCache->EndDataCache($arCacheData);
     }
     return $arData;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:52,代码来源:planner.php

示例11: GetData

 public static function GetData($courseId)
 {
     $arContents = array();
     $cacheId = 'course_id_' . (string) (int) $courseId;
     $oCache = new CPHPCache();
     if ($oCache->InitCache(self::TTL, $cacheId, self::CACHE_PATH) && !self::IsDirty()) {
         $arCached = $oCache->GetVars();
         if (isset($arCached['arContents']) && is_array($arCached['arContents'])) {
             $arContents = $arCached['arContents'];
         }
     } else {
         self::Purge();
         $arContents = self::GetDataWoCache($courseId);
         $oCache->StartDataCache(self::TTL, $cacheId, self::CACHE_PATH);
         $oCache->EndDataCache(array('arContents' => $arContents));
         self::MarkAsClean();
     }
     return $arContents;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:19,代码来源:clearncacheoflessontreecomponent.php

示例12: __construct

 private function __construct()
 {
     $cache = new CPHPCache();
     $cache_time = 2592000;
     // month
     $cache_id = self::$cacheKey;
     $cache_path = '/' . self::$cacheKey . '/';
     if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $vars = $cache->GetVars();
         $this->arIBlockIds = $vars['arIBlockIds'];
         $this->arPropertyIds = $vars['arPropertyIds'];
         $this->arPropertyValueIds = $vars['arPropertyValueIds'];
     } else {
         $cache->StartDataCache($cache_time, $cache_id, $cache_path);
         $this->SetIBlocks();
         $this->SetProperties();
         $cache->EndDataCache(array('arIBlockIds' => $this->arIBlockIds, 'arPropertyIds' => $this->arPropertyIds, 'arPropertyValueIds' => $this->arPropertyValueIds));
     }
 }
开发者ID:akmetainfo,项目名称:bitrix-iblock-tools,代码行数:19,代码来源:iblock_tools.php

示例13: getObject

 public function getObject($id, $code, $sectionCode = false, $iblock = false, $clear_cache = "N")
 {
     $id = (int) $id;
     $cache = new CPHPCache();
     if ($id) {
         $arFilter = array("ID" => $id);
         $cacheId = "object_" . $id . $sectionCode;
         $cachePath = "/" . SITE_ID . "/object/" . substr($id, 0, 3);
     } else {
         $arFilter = array("=CODE" => $code);
         $cacheId = "object_" . $code . $sectionCode;
         $cachePath = "/" . SITE_ID . "/object/" . substr($code, 0, 3);
     }
     if ($sectionCode) {
         $arFilter["SECTION_CODE"] = $sectionCode;
         $arFilter["!SECTION_ID"] = false;
     }
     if ($iblock) {
         $arFilter["IBLOCK_ID"] = $iblock;
     }
     // чистим кеш?
     if ('Y' == $clear_cache) {
         CPHPCache::clean($cacheId, $cachePath);
     }
     $cacheTime = CACHE_OBJECT;
     if ($cache->InitCache($cacheTime, $cacheId, $cachePath)) {
         $vars = $cache->GetVars();
         $obj = $vars["OBJECT"];
         return $obj;
     } else {
         $res = CIBlockElement::GetList(array(), $arFilter);
         if ($elem = $res->GetNextElement()) {
             $obj = $elem->GetFields();
             $props = $elem->GetProperties();
             $obj["PROPS"] = $props;
             if ($cache->StartDataCache()) {
                 $cache->EndDataCache(array("OBJECT" => $obj));
             }
             return $obj;
         }
     }
     return null;
 }
开发者ID:irotaev,项目名称:vector-vip.server,代码行数:43,代码来源:Iblock.php

示例14: getValueFromCache

 public static function getValueFromCache($cache_function, $cache_function_params, $nocache = false)
 {
     $result = null;
     $obj_cache = new CPHPCache();
     $cache_time = self::DEFAULT_CACHE_PERIOD;
     $cache_id = $cache_function . serialize($cache_function_params);
     $cache_path = '/drclinics/' . $cache_function . '/';
     if (!$nocache && $obj_cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $result = $obj_cache->GetVars();
     } else {
         if ($nocache || $obj_cache->StartDataCache($cache_time, $cache_id, $cache_path)) {
             $result = call_user_func_array(__CLASS__ . '::' . $cache_function, $cache_function_params);
             if (!$nocache) {
                 $obj_cache->EndDataCache($result);
             }
         }
     }
     return $result;
 }
开发者ID:romlg,项目名称:bitrixcode,代码行数:19,代码来源:DrclinicsHelper.php

示例15: getEntityByName

 /**
  * Ищет данные о сущности по ее названию
  * @param string $name
  * @return array
  */
 public static function getEntityByName($name)
 {
     if (empty(self::$_entities[$name]) || !array_key_exists($name, self::$_entities[$name])) {
         $cid = 'bxar\\helpers\\HlEntity_' . $name;
         $obCache = new \CPHPCache();
         if ($obCache->InitCache(7200, $cid, '/')) {
             self::$_entities[$name] = $obCache->GetVars();
         } elseif ($obCache->StartDataCache()) {
             $filter = ['select' => ['ID', 'NAME', 'TABLE_NAME'], 'filter' => ['NAME' => $name]];
             $hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList($filter)->fetch();
             if (!empty($hlblock['ID'])) {
                 self::$_entities[$name] = $hlblock;
             } else {
                 self::$_entities[$name] = null;
             }
             $obCache->EndDataCache(self::$_entities[$name]);
         }
     }
     return self::$_entities[$name];
 }
开发者ID:marvin255,项目名称:bxar,代码行数:25,代码来源:HlEntity.php


注:本文中的CPHPCache::InitCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。