1
|
|
|
<?php namespace Comodojo\Cache\Traits; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Cache\Components\ItemsIterator; |
|
|
|
|
4
|
|
|
use \Psr\Cache\CacheItemInterface; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @package Comodojo Cache |
8
|
|
|
* @author Marco Giovinazzi <[email protected]> |
9
|
|
|
* @license MIT |
10
|
|
|
* |
11
|
|
|
* LICENSE: |
12
|
|
|
* |
13
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
14
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
16
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
17
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
18
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
19
|
|
|
* THE SOFTWARE. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
trait BasicCacheItemPoolTrait { |
23
|
|
|
|
24
|
|
|
private $queue = []; |
25
|
|
|
|
26
|
3 |
|
public function getItems(array $keys = []) { |
27
|
|
|
|
28
|
3 |
|
$items = []; |
29
|
|
|
|
30
|
3 |
|
foreach ( $keys as $key ) { |
31
|
|
|
|
32
|
2 |
|
$items[$key] = $this->getItem($key); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
3 |
|
return $items; |
36
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
3 |
|
public function deleteItems(array $keys) { |
40
|
|
|
|
41
|
3 |
|
$result = []; |
42
|
|
|
|
43
|
3 |
|
foreach ( $keys as $key ) { |
44
|
|
|
|
45
|
3 |
|
$result[] = $this->deleteItem($key); |
|
|
|
|
46
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
3 |
|
return in_array(false, $result) ? false : true; |
50
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
3 |
|
public function saveDeferred(CacheItemInterface $item) { |
54
|
|
|
|
55
|
3 |
|
$this->checkQueueNamespace(true); |
56
|
|
|
|
57
|
3 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
58
|
|
|
|
59
|
3 |
|
$this->queue[$namespace][$item->getKey()] = $item; |
60
|
|
|
|
61
|
3 |
|
return true; |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
3 |
|
public function commit() { |
66
|
|
|
|
67
|
3 |
|
$result = []; |
68
|
|
|
|
69
|
3 |
|
$active_namespace = $this->getNamespace(); |
70
|
|
|
|
71
|
3 |
|
foreach ( $this->queue as $namespace => $queue ) { |
72
|
|
|
|
73
|
3 |
|
$this->setNamespace($namespace); |
|
|
|
|
74
|
|
|
|
75
|
3 |
|
foreach ( $queue as $key => $item ) { |
76
|
|
|
|
77
|
3 |
|
$result[] = $this->save($item); |
|
|
|
|
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
3 |
|
$this->queue = []; |
84
|
|
|
|
85
|
3 |
|
$this->setNamespace($active_namespace); |
86
|
|
|
|
87
|
3 |
|
return in_array(false, $result) ? false : true; |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
3 |
|
private function checkQueueNamespace($create = false) { |
92
|
|
|
|
93
|
3 |
|
$namespace = $this->getNamespace(); |
94
|
|
|
|
95
|
3 |
|
if ( array_key_exists($namespace, $this->queue) ) { |
96
|
1 |
|
return true; |
97
|
3 |
|
} else if ( $create ) { |
98
|
3 |
|
$this->queue[$namespace] = []; |
99
|
3 |
|
return true; |
100
|
|
|
} else { |
101
|
|
|
return false; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
} |
107
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths