- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/page_cache.php
- Класс: CPageCache
- Вызов: CPageCache::InitCache
function InitCache($TTL, $uniq_str, $initdir = false, $basedir = "cache")
{
/** @global CMain $APPLICATION */
global $APPLICATION, $USER;
if($initdir === false)
$initdir = $APPLICATION->GetCurDir();
$this->basedir = BX_PERSONAL_ROOT."/".$basedir."/";
$this->initdir = $initdir;
$this->filename = "/".CPageCache::GetPath($uniq_str);
$this->ttl = $TTL;
$this->uniq_str = $uniq_str;
if($TTL<=0)
return false;
if(is_object($USER) && $USER->CanDoOperation('cache_control'))
{
if(isset($_GET["clear_cache_session"]))
{
if(mb_strtoupper($_GET["clear_cache_session"]) == "Y")
BitrixMainApplication::getInstance()->getKernelSession()["SESS_CLEAR_CACHE"] = "Y";
elseif (!empty($_GET["clear_cache_session"]))
unset(BitrixMainApplication::getInstance()->getKernelSession()["SESS_CLEAR_CACHE"]);
}
if(isset($_GET["clear_cache"]) && mb_strtoupper($_GET["clear_cache"]) == "Y")
return false;
}
if(isset(BitrixMainApplication::getInstance()->getKernelSession()["SESS_CLEAR_CACHE"]) && BitrixMainApplication::getInstance()->getSession()["SESS_CLEAR_CACHE"] == "Y")
return false;
if(!$this->_cache->read($this->content, $this->basedir, $this->initdir, $this->filename, $this->ttl))
return false;
if (BitrixMainDataCache::getShowCacheStat())
{
$read = 0;
$path = '';
if ($this->_cache instanceof BitrixMainDataICacheEngineStat)
{
$read = $this->_cache->getReadBytes();
$path = $this->_cache->getCachePath();
}
elseif ($this->_cache instanceof ICacheBackend)
{
/** @noinspection PhpUndefinedFieldInspection */
$read = $this->_cache->read;
/** @noinspection PhpUndefinedFieldInspection */
$path = $this->_cache->path;
}
BitrixMainDiagCacheTracker::addCacheStatBytes($read);
BitrixMainDiagCacheTracker::add($read, $path, $this->basedir, $this->initdir, $this->filename, "R");
}
return true;
}