1
|
|
|
<?php namespace Comodojo\Cache\Providers; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Cache\Drivers\FilesystemXattr as FilesystemXattrDriver; |
4
|
|
|
use \Comodojo\Cache\Drivers\FilesystemGhost as FilesystemGhostDriver; |
5
|
|
|
use \Comodojo\Cache\Item; |
6
|
|
|
use \Comodojo\Cache\Components\EnhancedCacheItemPoolStats; |
7
|
|
|
use \Psr\Log\LoggerInterface; |
8
|
|
|
use \Comodojo\Exception\CacheException; |
9
|
|
|
use \Exception; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @package Comodojo Cache |
13
|
|
|
* @author Marco Giovinazzi <[email protected]> |
14
|
|
|
* @license MIT |
15
|
|
|
* |
16
|
|
|
* LICENSE: |
17
|
|
|
* |
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24
|
|
|
* THE SOFTWARE. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
class Filesystem extends AbstractEnhancedProvider { |
28
|
|
|
|
29
|
|
|
protected $default_properties = [ |
30
|
|
|
"cache_folder" => null |
31
|
|
|
]; |
32
|
|
|
|
33
|
28 |
|
public function __construct(array $properties = [], LoggerInterface $logger = null) { |
34
|
|
|
|
35
|
|
|
try { |
36
|
|
|
|
37
|
28 |
|
parent::__construct($properties, $logger); |
38
|
|
|
|
39
|
28 |
|
$cache_folder = $this->getProperties()->cache_folder; |
40
|
|
|
|
41
|
28 |
|
if ( empty($cache_folder) ) { |
42
|
|
|
throw new InvalidCacheArgumentException("Invalid or unspecified cache folder"); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
28 |
|
if ( $cache_folder[strlen($cache_folder) - 1] != "/" ) $cache_folder = "$cache_folder/"; |
46
|
|
|
|
47
|
28 |
|
if ( self::isXattrSupported($cache_folder) ) { |
48
|
|
|
$this->driver = new FilesystemXattrDriver(['cache-folder'=>$cache_folder]); |
49
|
|
|
} else { |
50
|
28 |
|
$this->driver = new FilesystemGhostDriver(['cache-folder'=>$cache_folder]); |
51
|
|
|
} |
52
|
|
|
|
53
|
28 |
|
$this->test(); |
54
|
|
|
|
55
|
|
|
} catch (Exception $e) { |
56
|
|
|
|
57
|
|
|
throw new CacheException($e->getMessage()); |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
28 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
1 |
|
public function getStats() { |
67
|
|
|
|
68
|
1 |
|
$info = $this->driver->stats(); |
69
|
|
|
|
70
|
1 |
|
return new EnhancedCacheItemPoolStats( |
71
|
1 |
|
$this->getId(), |
72
|
1 |
|
$this->driver->getName(), |
73
|
1 |
|
$this->getState(), |
74
|
1 |
|
$info['objects'], |
75
|
1 |
|
[] |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
28 |
|
protected static function isXattrSupported($folder) { |
81
|
|
|
|
82
|
28 |
|
return function_exists("xattr_supported") && xattr_supported($folder); |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
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