Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cachestorage.php
1<?php
3
6use Bitrix\Main\Data\ICacheEngine;
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 $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}
static getPath($uniqueString)
Definition cache.php:238
__construct(CacheEngineInterface $cacheEngine)