1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
cachestorage.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Data\LocalStorage\Storage;
4
5use Bitrix\Main\Application;
6use Bitrix\Main\Data\Cache;
7
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}
static getPersonalRoot()
Определения application.php:762
read(string $key, int $ttl)
Определения cachestorage.php:23
__construct(CacheEngineInterface $cacheEngine)
Определения cachestorage.php:17
write(string $key, $value, int $ttl)
Определения cachestorage.php:36
getPath()
Определения filesystementry.php:80
$filename
Определения file_edit.php:47
if(empty($signedUserToken)) $key
Определения quickway.php:257