1 | <?php |
||
10 | class MemoryCacheItemPool implements CacheItemPoolInterface { |
||
11 | /** @var array **/ |
||
12 | protected $items; |
||
13 | /** @var array **/ |
||
14 | protected $deferredItems; |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | 2 | public function deleteItem($key) { |
|
19 | 2 | if(isset($this->items[$key])) { |
|
|
|||
20 | 2 | unset($this->items[$key]); |
|
21 | } |
||
22 | 2 | if(isset($this->deferredItems[$key])) { |
|
23 | unset($this->deferredItems[$key]); |
||
24 | } |
||
25 | 2 | return true; |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 1 | public function deleteItems(array $keys) { |
|
32 | 1 | foreach($keys as $key) { |
|
33 | 1 | if(!$this->deleteItem($key)) { |
|
34 | 1 | return false; |
|
35 | } |
||
36 | } |
||
37 | 1 | return true; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | 9 | public function save(CacheItemInterface $item) { |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 2 | public function saveDeferred(CacheItemInterface $item) { |
|
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | 2 | public function commit() { |
|
62 | 2 | foreach($this->deferredItems as $key => $item) { |
|
63 | 2 | $this->items[$key] = $item; |
|
64 | 2 | unset($this->deferredItems[$key]); |
|
65 | } |
||
66 | 2 | return true; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 13 | public function hasItem($key) { |
|
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | 9 | public function getItem($key) { |
|
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | 3 | public function getItems(array $keys = array()) { |
|
90 | 3 | $items = []; |
|
91 | 3 | foreach($keys as $key) { |
|
92 | 3 | if($this->hasItem($key)) { |
|
93 | 3 | $items[$key] = $this->getItem($key); |
|
94 | } |
||
95 | } |
||
96 | 3 | return $items; |
|
97 | } |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | 1 | public function clear() { |
|
107 | } |