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/location/lib/common/ |
Upload File : |
<?php namespace Bitrix\Location\Common; use Bitrix\Main\Data\Cache; use Bitrix\Main\EventManager; /** * Class CachePool * @package Bitrix\Location\Common */ class CachedPool extends \Bitrix\Location\Common\Cache { /** @var Pool */ protected $pool; /** @var Cache */ protected $cache; /** @var bool */ protected $isItemChanged = false; /** * CachePool constructor. * @param Pool $pool * @param int $ttl * @param string $cacheId * @param Cache $cache * @param EventManager $eventManager */ public function __construct(Pool $pool, int $ttl, string $cacheId, Cache $cache, EventManager $eventManager) { $this->pool = $pool; parent::__construct($ttl, $cacheId, $cache, $eventManager); } public function loadDataFromCache(): void { $items = $this->cache->getVars()['items']; if(is_array($items)) { $this->pool->setItems($items); } } public function saveDataToCache(): void { if($this->isItemChanged) { $this->cache->forceRewriting(true); $this->cache->startDataCache(); $this->cache->endDataCache(['items' => $this->pool->getItems()]); } } /** * @param string $key * @return mixed */ public function getItem(string $key) { return $this->pool->getItem($key); } /** * @param string $key * @param mixed $value */ public function addItem(string $key, $value): void { $this->pool->addItem($key, $value); $this->isItemChanged = true; } /** * @param string $key */ public function deleteItem(string $key): void { $this->pool->deleteItem($key); $this->isItemChanged = true; } public function cleanItems(): void { $this->pool->cleanItems(); $this->isItemChanged = true; } }