1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
CacheManager.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\MessageService\Providers;
4
5
use Bitrix\Main\Data\Cache;
6
7
class
CacheManager
8
{
9
public
const
CHANNEL_CACHE_ENTITY_ID
=
'channel'
;
10
private
const
BASE_CACHE_DIR =
'/messageservice/'
;
11
private
const
CACHE_TTL = 86400;
//one hour
12
private
Cache
$cache;
13
private
string
$providerId;
14
18
public
function
__construct
(
string
$providerId)
19
{
20
$this->cache = Cache::createInstance();
21
$this->providerId = $providerId;
22
}
23
28
public
function
getTtl
(
string
$entityId
): int
29
{
30
return
self::CACHE_TTL;
31
}
32
38
public
function
getValue
(
string
$entityId
):
array
39
{
40
$result
= [];
41
if
($this->cache->initCache($this->getTtl(
$entityId
),
$entityId
, $this->getCacheDir()))
42
{
43
$result
= $this->cache->getVars();
44
}
45
46
return
$result
;
47
}
48
49
private
function
getCacheDir(): string
50
{
51
return
self::BASE_CACHE_DIR . $this->providerId;
52
}
53
54
public
function
setValue
(
string
$entityId
,
array
$value):
CacheManager
55
{
56
$cacheName =
$entityId
;
57
58
$this->cache->clean($cacheName, $this->getCacheDir());
59
60
$this->cache->initCache($this->
getTtl
($entityId), $cacheName, $this->getCacheDir());
61
$this->cache->startDataCache();
62
$this->cache->endDataCache($value);
63
64
return
$this;
65
}
66
67
public
function
deleteValue
(
string
$entityId
):
CacheManager
68
{
69
$cacheName =
$entityId
;
70
71
$this->cache->clean($cacheName, $this->getCacheDir());
72
73
return
$this;
74
}
75
}
Bitrix\MessageService\Providers\CacheManager
Определения
CacheManager.php:8
Bitrix\MessageService\Providers\CacheManager\getTtl
getTtl(string $entityId)
Определения
CacheManager.php:28
Bitrix\MessageService\Providers\CacheManager\__construct
__construct(string $providerId)
Определения
CacheManager.php:18
Bitrix\MessageService\Providers\CacheManager\getValue
getValue(string $entityId)
Определения
CacheManager.php:38
Bitrix\MessageService\Providers\CacheManager\deleteValue
deleteValue(string $entityId)
Определения
CacheManager.php:67
Bitrix\MessageService\Providers\CacheManager\CHANNEL_CACHE_ENTITY_ID
const CHANNEL_CACHE_ENTITY_ID
Определения
CacheManager.php:9
Bitrix\MessageService\Providers\CacheManager\setValue
setValue(string $entityId, array $value)
Определения
CacheManager.php:54
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Main\Data\Cache
Определения
keyvalueengine.php:3
$entityId
$entityId
Определения
payment.php:4
bitrix
modules
messageservice
lib
Providers
CacheManager.php
Создано системой
1.14.0