Total Complexity | 5 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class Local implements Storing |
||
15 | { |
||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $oid = null; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $block = []; |
||
25 | |||
26 | /** |
||
27 | * @var Eviction |
||
28 | */ |
||
29 | private $eviction = null; |
||
30 | |||
31 | /** |
||
32 | * Local constructor. |
||
33 | * @param Eviction $eviction |
||
34 | */ |
||
35 | public function __construct(Eviction $eviction) |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param string $key |
||
43 | * @return bool |
||
44 | */ |
||
45 | public function has(string $key) : bool |
||
46 | { |
||
47 | return isset($this->block[$key]); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param string $key |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function read(string $key) |
||
55 | { |
||
56 | return $this->block[$key] ?? null; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param string $key |
||
61 | * @param mixed $data |
||
62 | * @param int $ttl |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function write(string $key, $data, int $ttl = null) : bool |
||
66 | { |
||
67 | $this->block[$key] = $data; |
||
68 | $this->eviction->watch($this->oid, $key, $ttl); |
||
|
|||
69 | return true; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param string $key |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function remove(string $key) : bool |
||
80 | } |
||
81 | } |
||
82 |