本文整理汇总了PHP中CPHPCache::getVars方法的典型用法代码示例。如果您正苦于以下问题:PHP CPHPCache::getVars方法的具体用法?PHP CPHPCache::getVars怎么用?PHP CPHPCache::getVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPHPCache
的用法示例。
在下文中一共展示了CPHPCache::getVars方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: readManifestCache
public function readManifestCache($manifestId)
{
$cache = new \CPHPCache();
$cachePath = self::getCachePath($manifestId);
if ($cache->InitCache(3600 * 24 * 365, $manifestId, $cachePath)) {
return $cache->getVars();
}
return false;
}
示例8: 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);
}
示例9: 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;
}
示例10: executeComponent
public function executeComponent()
{
if (!CModule::IncludeModule('intranet')) {
ShowError(GetMessage('INTR_ISL_INTRANET_MODULE_NOT_INSTALLED'));
return;
}
if (!CModule::IncludeModule('socialnetwork')) {
return;
}
$showDepHeadAdditional = $this->arParams['SHOW_DEP_HEAD_ADDITIONAL'] == 'Y';
$bNav = $this->arParams['SHOW_NAV_TOP'] == 'Y' || $this->arParams['SHOW_NAV_BOTTOM'] == 'Y';
$isEnoughFiltered = $this->fillFilter();
list($cntStartCacheId, $cntStart) = $this->getCacheIdWithDepartment();
if ($this->arParams['SHOW_UNFILTERED_LIST'] == 'N' && !$this->bExcel && !$isEnoughFiltered) {
$this->arResult['EMPTY_UNFILTERED_LIST'] = 'Y';
$this->includeComponentTemplate();
return;
}
$this->arParams['bCache'] = $cntStart == count($this->arFilter) && !$this->bExcel && $this->arParams['CACHE_TYPE'] == 'Y' && $this->arParams['CACHE_TIME'] > 0;
$this->arResult['FILTER_VALUES'] = $this->arFilter;
if (!$this->bExcel && $bNav) {
CPageOption::SetOptionString("main", "nav_page_in_session", "N");
}
$bFromCache = false;
if ($this->arParams['bCache']) {
if ($bFromCache = $this->initCache($cntStartCacheId)) {
$vars = $this->obCache->getVars();
$this->arResult['USERS'] = $vars['USERS'];
$this->arResult['DEPARTMENTS'] = $vars['DEPARTMENTS'];
$this->arResult['DEPARTMENT_HEAD'] = $vars['DEPARTMENT_HEAD'];
$this->arResult['USERS_NAV'] = $vars['USERS_NAV'];
$strUserIDs = $vars['STR_USER_ID'];
} else {
$this->obCache->startDataCache();
$this->getCacheManager()->startTagCache($this->cacheDir);
$this->getCacheManager()->registerTag('intranet_users');
}
}
if (!$bFromCache) {
// get users list
$obUser = new CUser();
$arSelect = array('ID', 'ACTIVE', 'CONFIRM_CODE', 'DEP_HEAD', 'GROUP_ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'EMAIL', 'LID', 'DATE_REGISTER', 'PERSONAL_PROFESSION', 'PERSONAL_WWW', 'PERSONAL_ICQ', 'PERSONAL_GENDER', 'PERSONAL_BIRTHDATE', 'PERSONAL_PHOTO', 'PERSONAL_PHONE', 'PERSONAL_FAX', 'PERSONAL_MOBILE', 'PERSONAL_PAGER', 'PERSONAL_STREET', 'PERSONAL_MAILBOX', 'PERSONAL_CITY', 'PERSONAL_STATE', 'PERSONAL_ZIP', 'PERSONAL_COUNTRY', 'PERSONAL_NOTES', 'WORK_COMPANY', 'WORK_DEPARTMENT', 'WORK_POSITION', 'WORK_WWW', 'WORK_PHONE', 'WORK_FAX', 'WORK_PAGER', 'WORK_STREET', 'WORK_MAILBOX', 'WORK_CITY', 'WORK_STATE', 'WORK_ZIP', 'WORK_COUNTRY', 'WORK_PROFILE', 'WORK_LOGO', 'WORK_NOTES', 'PERSONAL_BIRTHDAY', 'LAST_ACTIVITY_DATE', 'LAST_LOGIN', 'IS_ONLINE');
$this->arResult['USERS'] = array();
$this->arResult['DEPARTMENTS'] = array();
$this->arResult['DEPARTMENT_HEAD'] = 0;
// disable/enable appearing of department head on page
if ($showDepHeadAdditional && !empty($this->arFilter['UF_DEPARTMENT']) && is_array($this->arFilter['UF_DEPARTMENT'])) {
if ($this->arParams['bCache']) {
$this->getCacheManager()->registerTag('intranet_department_' . $this->arFilter['UF_DEPARTMENT'][0]);
}
$managerId = CIntranetUtils::GetDepartmentManagerID($this->arFilter['UF_DEPARTMENT'][0]);
$appendManager = CUser::GetByID($managerId)->Fetch();
if ($appendManager) {
$this->arResult['DEPARTMENT_HEAD'] = $appendManager['ID'];
$this->arFilter['!ID'] = $appendManager['ID'];
$this->arResult['USERS'][$appendManager['ID']] = $appendManager;
}
}
$bDisable = false;
if (CModule::IncludeModule('extranet')) {
if (CExtranet::IsExtranetSite() && !CExtranet::IsExtranetAdmin()) {
$arIDs = array_merge(CExtranet::GetMyGroupsUsers(SITE_ID), CExtranet::GetPublicUsers());
if ($this->arParams['bCache']) {
$this->getCacheManager()->registerTag('extranet_public');
$this->getCacheManager()->registerTag('extranet_user_' . $this->getUser()->getID());
}
if (false !== ($key = array_search($this->getUser()->getID(), $arIDs))) {
unset($arIDs[$key]);
}
if (count($arIDs) > 0) {
$this->arFilter['ID'] = implode('|', array_unique($arIDs));
} else {
$bDisable = true;
}
}
}
if ($bDisable) {
$dbUsers = new CDBResult();
$dbUsers->initFromArray(array());
} else {
$arListParams = array('SELECT' => array('UF_*'), 'ONLINE_INTERVAL' => static::LAST_ACTIVITY);
if (!$this->bExcel && $this->arParams['USERS_PER_PAGE'] > 0) {
$arListParams['NAV_PARAMS'] = array('nPageSize' => $this->arParams['USERS_PER_PAGE'], 'bShowAll' => false);
}
$dbUsers = $obUser->GetList($sortBy = 'last_name', $sortDir = 'asc', $this->arFilter, $arListParams);
}
$strUserIDs = '';
while ($arUser = $dbUsers->Fetch()) {
$this->arResult['USERS'][$arUser['ID']] = $arUser;
$strUserIDs .= ($strUserIDs === '' ? '' : '|') . $arUser['ID'];
}
$structure = CIntranetUtils::getStructure();
$this->arResult['DEPARTMENTS'] = $structure['DATA'];
$this->setDepWhereUserIsHead();
$arAdmins = array();
/** @noinspection PhpUndefinedVariableInspection */
$rsUsers = CUser::GetList($o, $b, array("GROUPS_ID" => array(static::ADMIN_GROUP_ID)), array("SELECT" => array("ID")));
while ($ar = $rsUsers->Fetch()) {
$arAdmins[$ar["ID"]] = $ar["ID"];
}
//.........这里部分代码省略.........