Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
cachestorage.php
1
<?php
2
namespace
Bitrix\Main\Data\LocalStorage\Storage
;
3
4
use
Bitrix\Main\Application
;
5
use
Bitrix\Main\Data\Cache
;
6
use Bitrix\Main\Data\ICacheEngine;
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
$filename =
'/'
.
Cache::getPath
($key);
26
if
($this->cacheEngine->read($value, $this->baseDir, self::CACHE_DIR, $filename, $ttl))
27
{
28
return
$value;
29
}
30
31
return
null
;
32
}
33
34
public
function
write
(
string
$key, $value,
int
$ttl)
35
{
36
$filename =
'/'
.
Cache::getPath
($key);
37
$this->cacheEngine->write($value, $this->baseDir, self::CACHE_DIR, $filename, $ttl);
38
}
39
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getPersonalRoot
static getPersonalRoot()
Definition
application.php:743
Bitrix\Main\Data\Cache
Definition
cache.php:16
Bitrix\Main\Data\Cache\getPath
static getPath($uniqueString)
Definition
cache.php:238
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage
Definition
cachestorage.php:9
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\read
read(string $key, int $ttl)
Definition
cachestorage.php:23
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\__construct
__construct(CacheEngineInterface $cacheEngine)
Definition
cachestorage.php:17
Bitrix\Main\Data\LocalStorage\Storage\CacheStorage\write
write(string $key, $value, int $ttl)
Definition
cachestorage.php:34
Bitrix\Main\Data\LocalStorage\Storage\CacheEngineInterface
Definition
cacheengineinterface.php:5
Bitrix\Main\Data\LocalStorage\Storage\StorageInterface
Definition
storageinterface.php:5
Bitrix\Main\Data\LocalStorage\Storage
Definition
cacheengineinterface.php:2
modules
main
lib
data
localstorage
storage
cachestorage.php
Создано системой
1.10.0