本文整理汇总了PHP中CPHPCache::endDataCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CPHPCache::endDataCache方法的具体用法?PHP CPHPCache::endDataCache怎么用?PHP CPHPCache::endDataCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPHPCache
的用法示例。
在下文中一共展示了CPHPCache::endDataCache方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveComponentEngine
public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
{
/** @global CMain $APPLICATION */
global $APPLICATION, $CACHE_MANAGER;
$component = $engine->GetComponent();
if ($component) {
$iblock_id = intval($component->arParams["IBLOCK_ID"]);
} else {
$iblock_id = 0;
}
$requestURL = $APPLICATION->GetCurPage(true);
$cacheId = $requestURL . implode("|", array_keys($pageCandidates));
$cache = new CPHPCache();
if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->StartTagCache("iblock_find");
CIBlock::registerWithTagCache($iblock_id);
}
foreach ($pageCandidates as $pageID => $arVariablesTmp) {
if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
$arVariables = $arVariablesTmp;
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->EndTagCache();
}
$cache->endDataCache(array($pageID, $arVariablesTmp));
return $pageID;
}
}
}
foreach ($pageCandidates as $pageID => $arVariablesTmp) {
if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
$arVariables = $arVariablesTmp;
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->EndTagCache();
}
$cache->endDataCache(array($pageID, $arVariablesTmp));
return $pageID;
}
}
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->AbortTagCache();
}
$cache->abortDataCache();
} else {
$vars = $cache->getVars();
$pageID = $vars[0];
$arVariables = $vars[1];
return $pageID;
}
list($pageID, $arVariables) = each($pageCandidates);
return $pageID;
}
示例2: canRead
/**
* @param $userId
* @return bool
*/
public function canRead($userId)
{
if ($this->canRead !== null) {
return $this->canRead;
}
if (!Loader::includeModule('socialnetwork')) {
return false;
}
$cacheTtl = 2592000;
$cacheId = 'blog_post_socnet_general_' . $this->entityId . '_' . LANGUAGE_ID;
$timezoneOffset = \CTimeZone::getOffset();
if ($timezoneOffset != 0) {
$cacheId .= "_" . $timezoneOffset;
}
$cacheDir = '/blog/socnet_post/gen/' . intval($this->entityId / 100) . '/' . $this->entityId;
$cache = new \CPHPCache();
if ($cache->initCache($cacheTtl, $cacheId, $cacheDir)) {
$post = $cache->getVars();
} else {
$cache->startDataCache();
$queryPost = \CBlogPost::getList(array(), array("ID" => $this->entityId), false, false, array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR_ID", "ENABLE_COMMENTS", "NUM_COMMENTS", "VIEWS", "CODE", "MICRO", "DETAIL_TEXT", "DATE_PUBLISH", "CATEGORY_ID", "HAS_SOCNET_ALL", "HAS_TAGS", "HAS_IMAGES", "HAS_PROPS", "HAS_COMMENT_IMAGES"));
$post = $queryPost->fetch();
$cache->endDataCache($post);
}
if (!$post) {
$this->canRead = false;
return false;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$this->canRead = \CBlogPost::getSocNetPostPerms($this->entityId, true, $userId, $post["AUTHOR_ID"]) >= BLOG_PERMS_READ;
return $this->canRead;
}
示例3: getActiveTest
/**
* Returns active A/B-test
*
* @return array|null
*/
public static function getActiveTest()
{
static $abtest;
if (!defined('SITE_ID') || !SITE_ID) {
return null;
}
if (empty($abtest)) {
$cache = new \CPHPCache();
if ($cache->initCache(30 * 24 * 3600, 'abtest_active_' . SITE_ID, '/abtest')) {
$abtest = $cache->getVars();
} else {
$abtest = ABTestTable::getList(array('order' => array('SORT' => 'ASC'), 'filter' => array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', '<=START_DATE' => new \Bitrix\Main\Type\DateTime())))->fetch() ?: null;
$cache->startDataCache();
$cache->endDataCache($abtest);
}
if (!empty($abtest) && intval($abtest['DURATION']) > 0) {
$end = clone $abtest['START_DATE'];
$end->add(intval($abtest['DURATION']) . ' days');
if (time() > $end->format('U')) {
Helper::stopTest($abtest['ID'], true);
$abtest = null;
}
}
}
return $abtest;
}
示例4: workWithNonCacheAttr
/**
* Set mutable attributes
* @param bool $bFromCache
* @param string $strUserIds
*/
protected function workWithNonCacheAttr($bFromCache = false, $strUserIds = '')
{
//if list of users in cache - get last activity
if ($bFromCache && $strUserIds) {
$dbRes = CUser::getList($by = 'id', $order = 'asc', array('ID' => $strUserIds, 'LAST_ACTIVITY' => static::LAST_ACTIVITY), array('FIELDS' => array('ID')));
while ($arRes = $dbRes->fetch()) {
if ($this->arResult['USERS'][$arRes['ID']]) {
$this->arResult['USERS'][$arRes['ID']]['IS_ONLINE'] = true;
}
}
unset($dbRes, $arRes);
}
$buildResizedPhoto = false;
$displayPhoto = $this->displayPersonalPhoto();
foreach ($this->arResult['USERS'] as &$arUser) {
if ($this->bExcel && $displayPhoto) {
//if export in excel, then method $this->resizePersonalPhoto() not run. And not modify PERSONAL_PHOTO
if (!$arUser['PERSONAL_PHOTO']) {
$arUser['PERSONAL_PHOTO'] = $this->getDefaultPictureSonet($arUser['PERSONAL_GENDER']);
}
$arUser['PERSONAL_PHOTO_SOURCE'] = $arUser['PERSONAL_PHOTO'];
$arUser['PERSONAL_PHOTO'] = CFile::GetPath($arUser['PERSONAL_PHOTO']);
} elseif ($bFromCache && $displayPhoto) {
$buildResizedPhoto = $this->resizePersonalPhoto($arUser) || $buildResizedPhoto;
}
$arUser['IS_BIRTHDAY'] = CIntranetUtils::IsToday($arUser['PERSONAL_BIRTHDAY']);
$arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']);
}
//rewrite cache if we build new resized photo
if ($buildResizedPhoto) {
$this->obCache->clean($this->cacheId, $this->cacheDir);
$this->obCache->startDataCache();
$this->obCache->endDataCache(array('USERS' => $this->arResult['USERS'], 'STR_USER_ID' => $strUserIds, 'DEPARTMENTS' => $this->arResult['DEPARTMENTS'], 'DEPARTMENT_HEAD' => $this->arResult['DEPARTMENT_HEAD'], 'USERS_NAV' => $this->arResult['USERS_NAV']));
}
}
示例5: endResultCache
/**
* Function ends the caching block of the component execution.
*
* <p>Note: automaticly called by includeComponentTemplate.</p>
* @return void
*
*/
public final function endResultCache()
{
global $NavNum, $CACHE_MANAGER;
if (!$this->__bInited) {
return null;
}
if (!$this->__cache) {
return null;
}
$arCache = array("arResult" => $this->arResult);
if ($this->__template) {
$arCache["templateCachedData"] =& $this->__template->getCachedData();
if ($this->__component_epilog) {
$arCache["templateCachedData"]["component_epilog"] = $this->__component_epilog;
}
} else {
$arCache["templateCachedData"] = array();
}
if ($this->__NavNum !== false && $this->__NavNum !== $NavNum) {
$arCache["templateCachedData"]["__NavNum"] = $NavNum - $this->__NavNum;
}
if (!empty($this->__children_css)) {
$arCache["templateCachedData"]["__children_css"] = $this->__children_css;
if ($this->__parent) {
foreach ($this->__children_css as $cssPath) {
$this->__parent->addChildCSS($cssPath);
}
}
}
if (!empty($this->__children_js)) {
$arCache["templateCachedData"]["__children_js"] = $this->__children_js;
if ($this->__parent) {
foreach ($this->__children_js as $jsPath) {
$this->__parent->addChildJS($jsPath);
}
}
}
if (!empty($this->__children_epilogs)) {
$arCache["templateCachedData"]["__children_epilogs"] = $this->__children_epilogs;
if ($this->__parent) {
foreach ($this->__children_epilogs as $epilogFile) {
$this->__parent->addChildEpilog($epilogFile);
}
}
}
if (!empty($this->__view)) {
$arCache["templateCachedData"]["__view"] = $this->__view;
}
if (!empty($this->__editButtons)) {
$arCache["templateCachedData"]["__editButtons"] = $this->__editButtons;
}
$cacheWasStarted = $this->__cache->isStarted();
$this->__cache->endDataCache($arCache);
if (defined("BX_COMP_MANAGED_CACHE") && $cacheWasStarted) {
$CACHE_MANAGER->endTagCache();
}
$this->__cache = null;
}
示例6: parsePath
protected function parsePath($requestUri)
{
static $storages;
if (empty($storages)) {
$cache = new \CPHPCache();
if ($cache->initCache(30 * 24 * 3600, 'webdav_disk_common_storage', '/webdav/storage')) {
$storages = $cache->getVars();
} else {
$storages = \Bitrix\Disk\Storage::getModelList(array('filter' => array('=ENTITY_TYPE' => \Bitrix\Disk\ProxyType\Common::className())));
foreach ($storages as $key => $storage) {
$storages[$key] = array('id' => $storage->getEntityId(), 'path' => $storage->getProxyType()->getStorageBaseUrl());
}
$cache->startDataCache();
if (defined('BX_COMP_MANAGED_CACHE')) {
$taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache();
$taggedCache->startTagCache('/webdav/storage');
$taggedCache->registerTag('disk_common_storage');
$taggedCache->endTagCache();
}
$cache->endDataCache($storages);
}
}
$patterns = array(array('user', '/(?:company|contacts)/personal/user/(\\d+)/files/lib(.*)$'), array('user', '/(?:company|contacts)/personal/user/(\\d+)/disk/path(.*)$'), array('group', '/workgroups/group/(\\d+)/files(.*)$'), array('group', '/workgroups/group/(\\d+)/disk/path(.*)$'));
foreach ($storages as $storage) {
$storagePath = trim($storage['path'], '/');
$patterns[] = array('docs', sprintf('^/%s/path(.*)$', $storagePath), $storage['id']);
$patterns[] = array('docs', sprintf('^/%s(.*)$', $storagePath), $storage['id']);
}
// @TODO: aggregator
$patterns[] = array('docs', '^/docs/path(.*)$', 'shared_files_s1');
$patterns[] = array('docs', '^/docs(.*)$', 'shared_files_s1');
$type = null;
$id = null;
$path = null;
foreach ($patterns as $pattern) {
$matches = array();
if (preg_match('#' . $pattern[1] . '#i', $requestUri, $matches)) {
$type = $pattern[0];
list($id, $path) = $type == 'docs' ? array($pattern[2], $matches[1]) : array($matches[1], $matches[2]);
break;
}
}
/** @var Storage $storage */
$storage = null;
if ($type == 'user') {
$storage = Driver::getInstance()->getStorageByUserId((int) $id);
} elseif ($type == 'group') {
$storage = Driver::getInstance()->getStorageByGroupId((int) $id);
} elseif ($type == 'docs') {
$storage = Driver::getInstance()->getStorageByCommonId($id);
} else {
return array(null, null);
}
$path = static::UrlDecode($path);
return array($storage, $path);
}
示例7: getActiveTest
/**
* Returns active A/B-test
*
* @return array|null
*/
public static function getActiveTest()
{
static $abtest;
static $defined;
if (!defined('SITE_ID') || !SITE_ID) {
return null;
}
if (empty($defined)) {
$cache = new \CPHPCache();
if ($cache->initCache(30 * 24 * 3600, 'abtest_active_' . SITE_ID, '/abtest')) {
$abtest = $cache->getVars();
} else {
$abtest = ABTestTable::getList(array('order' => array('SORT' => 'ASC'), 'filter' => array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', '<=START_DATE' => new Type\DateTime())))->fetch() ?: null;
$cache->startDataCache();
$cache->endDataCache($abtest);
}
$defined = true;
if (!empty($abtest)) {
if (!$abtest['MIN_AMOUNT']) {
$capacity = AdminHelper::getSiteCapacity($abtest['SITE_ID']);
if ($capacity['min'] > 0) {
$result = ABTestTable::update($abtest['ID'], array('MIN_AMOUNT' => $capacity['min']));
if ($result->isSuccess()) {
$cache->clean('abtest_active_' . SITE_ID, '/abtest');
$abtest['MIN_AMOUNT'] = $capacity['min'];
}
}
}
if (intval($abtest['DURATION']) == -1) {
if (intval($abtest['MIN_AMOUNT']) > 0) {
$capacity = AdminHelper::getTestCapacity($abtest['ID']);
if ($capacity['A'] >= $abtest['MIN_AMOUNT'] && $capacity['B'] >= $abtest['MIN_AMOUNT']) {
Helper::stopTest($abtest['ID'], true);
$abtest = null;
}
}
} else {
if (intval($abtest['DURATION']) > 0) {
$end = clone $abtest['START_DATE'];
$end->add(intval($abtest['DURATION']) . ' days');
if (time() > $end->format('U')) {
Helper::stopTest($abtest['ID'], true);
$abtest = null;
}
}
}
}
}
return $abtest;
}
示例8: resolveComponentEngine
public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
{
/** @global CMain $APPLICATION */
global $APPLICATION, $CACHE_MANAGER;
static $aSearch = array("<", ">", """, "'");
static $aReplace = array("<", ">", "\"", "'");
$component = $engine->GetComponent();
if ($component) {
$iblock_id = intval($component->arParams["IBLOCK_ID"]);
} else {
$iblock_id = 0;
}
//To fix GetPagePath security hack for SMART_FILTER_PATH
foreach ($pageCandidates as $pageID => $arVariablesTmp) {
foreach ($arVariablesTmp as $variableName => $variableValue) {
if ($variableName === "SMART_FILTER_PATH") {
$pageCandidates[$pageID][$variableName] = str_replace($aSearch, $aReplace, $variableValue);
}
}
}
$requestURL = $APPLICATION->GetCurPage(true);
$cacheId = $requestURL . implode("|", array_keys($pageCandidates)) . "|" . SITE_ID;
$cache = new CPHPCache();
if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->StartTagCache("iblock_find");
CIBlock::registerWithTagCache($iblock_id);
}
foreach ($pageCandidates as $pageID => $arVariablesTmp) {
if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
$arVariables = $arVariablesTmp;
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->EndTagCache();
}
$cache->endDataCache(array($pageID, $arVariablesTmp));
return $pageID;
}
}
}
foreach ($pageCandidates as $pageID => $arVariablesTmp) {
if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
$arVariables = $arVariablesTmp;
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->EndTagCache();
}
$cache->endDataCache(array($pageID, $arVariablesTmp));
return $pageID;
}
}
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$CACHE_MANAGER->AbortTagCache();
}
$cache->abortDataCache();
} else {
$vars = $cache->getVars();
$pageID = $vars[0];
$arVariables = $vars[1];
return $pageID;
}
reset($pageCandidates);
list($pageID, $arVariables) = each($pageCandidates);
return $pageID;
}
示例9: getTestCapacity
/**
* Returns A/B-test traffic amounts
*
* @param int $id A/B-test ID.
* @return array
*/
public static function getTestCapacity($id)
{
$cache = new \CPHPCache();
if ($cache->initCache(time() - strtotime('today'), 'abtest_capacity_' . intval($id), '/abtest')) {
$capacity = $cache->getVars();
} else {
if (Loader::includeModule('conversion')) {
if ($conversionRates = Conversion\RateManager::getTypes(array('ACTIVE' => true))) {
if ($abtest = ABTestTable::getById($id)->fetch()) {
$lid = $abtest['SITE_ID'];
$baseRate = array_slice($conversionRates, 0, 1, true);
$reportContext = new Conversion\ReportContext();
$reportContext->setAttribute('conversion_site', $lid);
$reportContext->setAttribute('abtest', $id);
$reportContext->setAttribute('abtest_section', 'A');
$groupAData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
$reportContext->unsetAttribute('abtest_section', 'A');
$reportContext->setAttribute('abtest_section', 'B');
$groupBData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
$capacity = array('A' => $groupAData['DENOMINATOR'], 'B' => $groupBData['DENOMINATOR']);
$cache->startDataCache(strtotime('tomorrow') - time());
$cache->endDataCache($capacity);
}
}
}
}
return !empty($capacity) ? $capacity : array('A' => 0, 'B' => 0);
}
示例10: getDataToCheck
private static function getDataToCheck($messageId)
{
$return = false;
if ($messageId > 0 && Loader::includeModule("forum")) {
if (!array_key_exists($messageId, self::$messages)) {
$cacheTtl = 2592000;
$cacheId = 'forum_message_' . $messageId;
$cachePath = \CComponentEngine::makeComponentPath("forum.topic.read");
$cache = new \CPHPCache();
$messages = $topics = array();
if ($cache->initCache($cacheTtl, $cacheId, $cachePath)) {
list($messages, $topics) = $cache->getVars();
} else {
$dbRes = \CForumMessage::getListEx(array("ID" => "ASC"), array("TOPIC" => "Y", "TOPIC_MESSAGE_ID" => $messageId, ">=ID" => $messageId), false, 10);
while ($res = $dbRes->fetch()) {
$messages["M" . $res["ID"]] = array_intersect_key($res, array("ID" => "", "TOPIC_ID" => "", "FORUM_ID" => "", "USER_ID" => "", "NEW_TOPIC" => "", "PARAM1" => "", "PARAM2" => ""));
if (!array_key_exists("T" . $res["TOPIC_ID"], $topics)) {
$topics["T" . $res["TOPIC_ID"]] = array("TITLE" => $res["TITLE"], "USER_ID" => $res["USER_START_ID"], "XML_ID" => $res["TOPIC_XML_ID"], "SOCNET_GROUP_ID" => $res["TOPIC_SOCNET_GROUP_ID"], "OWNER_ID" => $res["TOPIC_OWNER_ID"]);
}
}
if (!empty($messages)) {
$cache->startDataCache();
$res = reset($topics);
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
\CForumCacheManager::setTag($cachePath, "forum_topic_" . $res['ID']);
$cache->endDataCache(array($messages, $topics));
}
}
self::$messages += $messages;
self::$topics += $topics;
}
if (array_key_exists("M" . $messageId, self::$messages)) {
$return = array(self::$messages["M" . $messageId], self::$topics["T" . self::$messages["M" . $messageId]["TOPIC_ID"]], \CForumNew::getByIDEx(self::$messages["M" . $messageId]["FORUM_ID"], SITE_ID));
}
}
return $return;
}