Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class FileBoundMemoryAdapter implements FileBoundCacheInterface |
||
11 | { |
||
12 | /** @var array<string, mixed> */ |
||
13 | private $items; |
||
14 | /** @var FileBoundCacheInterface */ |
||
15 | private $fileBoundCache; |
||
16 | |||
17 | public function __construct(FileBoundCacheInterface $fileBoundCache) |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Fetches an element from the cache by key. |
||
24 | * |
||
25 | * @return mixed |
||
26 | */ |
||
27 | public function get(string $key) |
||
28 | { |
||
29 | if (isset($this->items[$key])) { |
||
30 | return $this->items[$key]; |
||
31 | } |
||
32 | |||
33 | return $this->items[$key] = $this->fileBoundCache->get($key); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Stores an item in the cache. |
||
38 | * |
||
39 | * @param mixed $item The item must be serializable. |
||
40 | * @param array<int, string> $fileNames If one of these files is touched, the cache item is invalidated. |
||
41 | */ |
||
42 | public function set(string $key, $item, array $fileNames, ?int $ttl = null): void |
||
46 | } |
||
47 | } |
||
48 |