Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/classes/general/ |
Upload File : |
<?php /** * Bitrix Framework * @package bitrix * @subpackage main * @copyright 2001-2023 Bitrix */ class CStackCacheManager { /** @var CStackCacheEntry[] */ var $cache = array(); var $cacheLen = array(); var $cacheTTL = array(); var $eventHandlerAdded = false; function SetLength($entity, $length) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if(isset($this->cache[$entity]) && is_object($this->cache[$entity])) $this->cache[$entity]->SetLength($length); else $this->cacheLen[$entity] = $length; } function SetTTL($entity, $ttl) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if(isset($this->cache[$entity]) && is_object($this->cache[$entity])) $this->cache[$entity]->SetTTL($ttl); else $this->cacheTTL[$entity] = $ttl; } function Init($entity, $length = 0, $ttl = 0) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if (!$this->eventHandlerAdded) { AddEventHandler("main", "OnEpilog", array("CStackCacheManager", "SaveAll")); $this->eventHandlerAdded = true; } if($length <= 0 && isset($this->cacheLen[$entity])) $length = $this->cacheLen[$entity]; if($ttl <= 0 && isset($this->cacheTTL[$entity])) $ttl = $this->cacheTTL[$entity]; if (!array_key_exists($entity, $this->cache)) $this->cache[$entity] = new CStackCacheEntry($entity, $length, $ttl); } function Load($entity) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if (!array_key_exists($entity, $this->cache)) $this->Init($entity); $this->cache[$entity]->Load(); } //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE function Clear($entity, $id = false) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if (!array_key_exists($entity, $this->cache)) $this->Load($entity); if ($id !== false) $this->cache[$entity]->DeleteEntry($id); else $this->cache[$entity]->Clean(); } // Clears all managed_cache function CleanAll() { $this->cache = array(); $objCache = new CPHPCache; $objCache->CleanDir(false, "stack_cache"); } //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE function Exist($entity, $id) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return false; if (!array_key_exists($entity, $this->cache)) $this->Load($entity); return array_key_exists($id, $this->cache[$entity]->values); } //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE function Get($entity, $id) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return false; if (!array_key_exists($entity, $this->cache)) $this->Load($entity); return $this->cache[$entity]->Get($id); } //NO ONE SHOULD NEVER EVER USE INTEGER $id HERE function Set($entity, $id, $value) { if (defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if (!array_key_exists($entity, $this->cache)) $this->Load($entity); $this->cache[$entity]->Set($id, $value); } function Save($entity) { if(defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; if(array_key_exists($entity, $this->cache)) $this->cache[$entity]->Save(); } public static function SaveAll() { if(defined("BITRIX_SKIP_STACK_CACHE") && BITRIX_SKIP_STACK_CACHE) return; /** @global CStackCacheManager $stackCacheManager */ global $stackCacheManager; foreach($stackCacheManager->cache as $value) { $value->Save(); } } function MakeIDFromArray($values) { $id = "id"; sort($values); for ($i = 0, $c = count($values); $i < $c; $i++) $id .= "_".$values[$i]; return $id; } }