Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Cache.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Space\Cache
;
4
5
use \Bitrix\Main\Data;
6
7
class
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
}
Bitrix\Main\Data\Cache
Definition
cache.php:16
Bitrix\Main\Data\Cache\initCache
initCache($ttl, $uniqueString, $initDir=false, $baseDir='cache')
Definition
cache.php:271
Bitrix\Socialnetwork\Space\Cache\Cache\initCache
initCache()
Definition
Cache.php:37
Bitrix\Socialnetwork\Space\Cache\Cache\__construct
__construct(private int $userId, private int $spaceId)
Definition
Cache.php:15
Bitrix\Socialnetwork\Space\Cache\Cache\CACHE_ID
const CACHE_ID
Definition
Cache.php:9
Bitrix\Socialnetwork\Space\Cache\Cache\store
store(array $data)
Definition
Cache.php:20
Bitrix\Socialnetwork\Space\Cache
Definition
Cache.php:3
modules
socialnetwork
lib
Space
Cache
Cache.php
Создано системой
1.10.0