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/ilovecveti.ru/bitrix/modules/socialnetwork/lib/Space/Cache/ |
Upload File : |
<?php namespace Bitrix\Socialnetwork\Space\Cache; use \Bitrix\Main\Data; class Cache { public const CACHE_ID = 'socialnetwork-toolbar-composition-'; private const TTL = 86400; private const DIRECTORY = 'socialnetwork'; private Data\Cache $cache; public function __construct(private int $userId, private int $spaceId) { $this->init(); } public function store(array $data): void { $this->cache->forceRewriting(true); $this->cache->startDataCache(); $this->cache->endDataCache($data); } public function get(): array { if (!$this->initCache()) { return []; } $variables = $this->cache->getVars(); return is_array($variables) ? $variables : []; } public function initCache(): bool { return $this->cache->initCache(static::TTL, $this->getCacheId(), static::DIRECTORY); } private function init(): void { $this->cache = Data\Cache::createInstance(); $this->initCache(); } private function getCacheId(): string { return static::CACHE_ID . $this->userId . '-' . $this->spaceId; } }