1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Cache.php
См. документацию.
1<?php
2
4
5use \Bitrix\Main\Data;
6
7class Cache
8{
9 public const CACHE_ID = 'socialnetwork-toolbar-composition-';
10 private const TTL = 86400;
11 private const DIRECTORY = 'socialnetwork';
12
13 private Data\Cache $cache;
14
15 public function __construct(private int $userId, private int $spaceId)
16 {
17 $this->init();
18 }
19
20 public function store(array $data): void
21 {
22 $this->cache->forceRewriting(true);
23 $this->cache->startDataCache();
24 $this->cache->endDataCache($data);
25 }
26
27 public function get(): array
28 {
29 if (!$this->initCache())
30 {
31 return [];
32 }
33 $variables = $this->cache->getVars();
34 return is_array($variables) ? $variables : [];
35 }
36
37 public function initCache(): bool
38 {
39 return $this->cache->initCache(static::TTL, $this->getCacheId(), static::DIRECTORY);
40 }
41
42 private function init(): void
43 {
44 $this->cache = Data\Cache::createInstance();
45 $this->initCache();
46 }
47
48 private function getCacheId(): string
49 {
50 return static::CACHE_ID . $this->userId . '-' . $this->spaceId;
51 }
52}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
__construct(private int $userId, private int $spaceId)
Определения Cache.php:15
store(array $data)
Определения Cache.php:20
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804