1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
cachestorage.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Data\LocalStorage\Storage;
4
5
use Bitrix\Main\Application;
6
use Bitrix\Main\Data\Cache;
7
8
class
CacheStorage
implements
StorageInterface
9
{
10
private
const
CACHE_DIR =
'local-session'
;
11
13
private
$baseDir;
15
private
$cacheEngine;
16
17
public
function
__construct
(
CacheEngineInterface
$cacheEngine)
18
{
19
$this->cacheEngine = $cacheEngine;
20
$this->baseDir =
Application::getPersonalRoot
() .
'/cache/'
;
21
}
22
23
public
function
read
(
string
$key
,
int
$ttl)
24
{
25
$initDir = $this->getDirname(
$key
);
26
$filename
= $this->getFilename(
$key
);
27
28
if
($this->cacheEngine->read($value, $this->baseDir, $initDir,
$filename
, $ttl))
29
{
30
return
$value;
31
}
32
33
return
null
;
34
}
35
36
public
function
write
(
string
$key
, $value,
int
$ttl)
37
{
38
$initDir = $this->getDirname(
$key
);
39
$filename
= $this->getFilename(
$key
);
40
41
$this->cacheEngine->write($value, $this->baseDir, $initDir,
$filename
, $ttl);
42
}
43
44
private
function
getDirname(
string
$key
): string
45
{
46
return
self::CACHE_DIR .
'/'
. substr(md5(
$key
), 0, 3);
47
}
48
49
private
function
getFilename(
string
$key
): string
50
{
51
return
'/'
.
Cache::getPath
(
$key
);
52
}
53
}
Bitrix\Main\Application\getPersonalRoot
static getPersonalRoot()
Определения
application.php:762
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage
Определения
cachestorage.php:9
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\read
read(string $key, int $ttl)
Определения
cachestorage.php:23
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\__construct
__construct(CacheEngineInterface $cacheEngine)
Определения
cachestorage.php:17
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\write
write(string $key, $value, int $ttl)
Определения
cachestorage.php:36
Bitrix\Main\IO\FileSystemEntry\getPath
getPath()
Определения
filesystementry.php:80
$filename
$filename
Определения
file_edit.php:47
Bitrix\Main\Data\CacheEngineInterface
Определения
cacheengineinterface.php:6
Bitrix\Main\Data\LocalStorage\Storage\StorageInterface
Определения
storageinterface.php:5
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
bitrix
modules
main
lib
data
localstorage
storage
cachestorage.php
Создано системой
1.14.0