10namespace Bitrix\Main\Data;
13use Bitrix\Main\Config;
43 static $instances = [];
46 if (isset($instances[
$hash]))
48 return clone $instances[
$hash];
56 if (!empty($v[
'type']))
58 $cacheType = $v[
'type'];
61 if (is_array($cacheType))
63 if (isset($cacheType[
'class_name']))
65 if (!isset($cacheType[
'extension']) || extension_loaded($cacheType[
'extension']))
67 if (isset($cacheType[
'required_file']) && ($requiredFile =
Main\
Loader::getLocal($cacheType[
'required_file'])) !==
false)
69 require_once($requiredFile);
72 if (isset($cacheType[
'required_remote_file']))
74 require_once($cacheType[
'required_remote_file']);
77 $className = $cacheType[
'class_name'];
78 if (class_exists($className))
114 trigger_error(
'Cache engine is not found', E_USER_WARNING);
120 trigger_error(
'Cache engine is not available', E_USER_WARNING);
130 $obj = static::createCacheEngine();
131 $class = get_class($obj);
132 if (($pos = strrpos($class,
"\\")) !==
false)
134 $class = substr($class, $pos + 1);
137 return strtolower($class);
157 return static::$showCacheStat;
183 $scriptName = $server->get(
'SCRIPT_NAME');
184 if ($scriptName ==
'/bitrix/urlrewrite.php' && (($v = $server->get(
'REAL_FILE_PATH')) !=
null))
188 elseif ($scriptName ==
'/404.php' && (($v = $server->get(
'REAL_FILE_PATH')) !=
null))
192 return '/' . mb_substr(md5($scriptName), 0, 3);
212 if (isset(static::$clearCacheSession) || isset(static::$clearCache))
214 if (
$USER instanceof \CUser &&
$USER->CanDoOperation(
'cache_control'))
216 if (isset(static::$clearCacheSession))
218 if (static::$clearCacheSession ===
true)
228 if (isset(static::$clearCache) && (static::$clearCache ===
true))
246 return mb_substr($un, 0, 2) .
'/' . $un .
'.php';
255 if (static::$showCacheStat)
268 if (static::$showCacheStat)
284 $this->baseDir = $personalRoot .
'/' .
$baseDir .
'/';
291 if ($ttl <= 0 || $this->
forceRewriting || static::shouldClearCache())
296 $data = [
'CONTENT' =>
'',
'VARS' =>
''];
297 if (!$this->cacheEngine->read(
$data, $this->baseDir, $this->initDir, $this->filename, $this->ttl))
307 if (static::$showCacheStat)
313 $read = $this->cacheEngine->getReadBytes();
314 $path = $this->cacheEngine->getCachePath();
321 $this->content =
$data[
'CONTENT'];
322 $this->vars =
$data[
'VARS'];
329 if ($this->hasOutput)
337 $this->hasOutput =
false;
347 $narg = func_num_args();
379 if ($this->hasOutput)
398 if ($this->hasOutput)
413 'CONTENT' => $this->hasOutput ? ob_get_contents() :
'',
414 'VARS' => (
$vars !==
false ?
$vars : $this->vars),
417 $this->cacheEngine->write(
$data, $this->baseDir, $this->initDir, $this->filename, $this->ttl);
419 if (static::$showCacheStat)
425 $written = $this->cacheEngine->getWrittenBytes();
426 $path = $this->cacheEngine->getCachePath();
433 if ($this->hasOutput)
435 if (ob_get_contents() <>
'')
448 return $this->cacheEngine->isCacheExpired(
$path);
453 return $this->isStarted;
463 if (
$initDir ===
'' && is_string($full))
471 $cache = static::createInstance();
clean($uniqueString, $initDir=false, $baseDir='cache')
endDataCache($vars=false)
static clearCache($full=false, $initDir='')
static createInstance($params=[])
static getCacheEngineType()
static setClearCacheSession($clearCacheSession)
static shouldClearCache()
static $clearCacheSession
static setClearCache($clearCache)
cleanDir($initDir=false, $baseDir='cache')
__construct($cacheEngine)
static getPath($uniqueString)
CacheEngineInterface $cacheEngine
static setShowCacheStat($showCacheStat)
static createCacheEngine($params=[])
startDataCache($TTL=false, $uniqueString=false, $initDir=false, $vars=array(), $baseDir='cache')
initCache($ttl, $uniqueString, $initDir=false, $baseDir='cache')
static getShowCacheStat()
static addCacheStatBytes($cacheStatBytes)
static add($size, $path, $baseDir, $initDir, $filename, $operation)
static getLocal($path, $root=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']