1 | <?php |
||
10 | class AdapterArray implements iAdapter |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | private static $values = []; |
||
16 | |||
17 | /** |
||
18 | * @var array<string, array<int>> |
||
19 | */ |
||
20 | private static $expired = []; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 13 | public function exists(string $key): bool |
|
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | 11 | public function get(string $key) |
|
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function installed(): bool |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 1 | public function remove(string $key): bool |
|
52 | { |
||
53 | 1 | $this->removeExpired($key); |
|
54 | |||
55 | 1 | if (\array_key_exists($key, self::$values) === true) { |
|
56 | 1 | unset(self::$values[$key]); |
|
57 | |||
58 | 1 | return true; |
|
59 | } |
||
60 | |||
61 | return false; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | 1 | public function removeAll(): bool |
|
68 | { |
||
69 | 1 | self::$values = []; |
|
70 | 1 | self::$expired = []; |
|
71 | |||
72 | 1 | return true; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 6 | public function set(string $key, $value): bool |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 4 | public function setExpired(string $key, $value, int $ttl = 0): bool |
|
98 | |||
99 | /** |
||
100 | * Remove expired cache. |
||
101 | * |
||
102 | * @param string $key |
||
103 | * |
||
104 | * @return bool |
||
105 | */ |
||
106 | 13 | private function removeExpired($key): bool |
|
130 | } |
||
131 |