@@ 29-77 (lines=49) @@ | ||
26 | * THE SOFTWARE. |
|
27 | */ |
|
28 | ||
29 | class Filesystem extends AbstractEnhancedProvider { |
|
30 | ||
31 | public function __construct($cache_folder, LoggerInterface $logger = null) { |
|
32 | ||
33 | try { |
|
34 | ||
35 | if ( empty($cache_folder) ) { |
|
36 | throw new InvalidCacheArgumentException("Invalid or unspecified cache folder"); |
|
37 | } |
|
38 | ||
39 | if ( $cache_folder[strlen($cache_folder) - 1] != "/" ) $cache_folder = "$cache_folder/"; |
|
40 | ||
41 | if ( self::isXattrSupported($cache_folder) ) { |
|
42 | $this->driver = new FilesystemXattrDriver(['cache-folder'=>$cache_folder]); |
|
43 | } else { |
|
44 | $this->driver = new FilesystemGhostDriver(['cache-folder'=>$cache_folder]); |
|
45 | } |
|
46 | ||
47 | parent::__construct($logger); |
|
48 | ||
49 | } catch (Exception $e) { |
|
50 | ||
51 | throw new CacheException($e->getMessage()); |
|
52 | ||
53 | } |
|
54 | ||
55 | } |
|
56 | ||
57 | public function getStats() { |
|
58 | ||
59 | $info = $this->driver->stats(); |
|
60 | ||
61 | return new EnhancedCacheItemPoolStats( |
|
62 | $this->getId(), |
|
63 | $this->driver->getName(), |
|
64 | $this->getState(), |
|
65 | $info, |
|
66 | [] |
|
67 | ); |
|
68 | ||
69 | } |
|
70 | ||
71 | protected static function isXattrSupported($folder) { |
|
72 | ||
73 | return function_exists("xattr_supported") && xattr_supported($folder); |
|
74 | ||
75 | } |
|
76 | ||
77 | } |
|
78 |
@@ 29-77 (lines=49) @@ | ||
26 | * THE SOFTWARE. |
|
27 | */ |
|
28 | ||
29 | class Filesystem extends AbstractEnhancedProvider { |
|
30 | ||
31 | public function __construct($cache_folder, LoggerInterface $logger = null) { |
|
32 | ||
33 | try { |
|
34 | ||
35 | if ( empty($cache_folder) ) { |
|
36 | throw new InvalidSimpleCacheArgumentException("Invalid or unspecified cache folder"); |
|
37 | } |
|
38 | ||
39 | if ( $cache_folder[strlen($cache_folder) - 1] != "/" ) $cache_folder = "$cache_folder/"; |
|
40 | ||
41 | if ( self::isXattrSupported($cache_folder) ) { |
|
42 | $this->driver = new FilesystemXattrDriver(['cache-folder'=>$cache_folder]); |
|
43 | } else { |
|
44 | $this->driver = new FilesystemGhostDriver(['cache-folder'=>$cache_folder]); |
|
45 | } |
|
46 | ||
47 | parent::__construct($logger); |
|
48 | ||
49 | } catch (Exception $e) { |
|
50 | ||
51 | throw new SimpleCacheException($e->getMessage()); |
|
52 | ||
53 | } |
|
54 | ||
55 | } |
|
56 | ||
57 | public function getStats() { |
|
58 | ||
59 | $info = $this->driver->stats(); |
|
60 | ||
61 | return new EnhancedCacheItemPoolStats( |
|
62 | $this->getId(), |
|
63 | $this->driver->getName(), |
|
64 | $this->getState(), |
|
65 | $info, |
|
66 | [] |
|
67 | ); |
|
68 | ||
69 | } |
|
70 | ||
71 | protected static function isXattrSupported($folder) { |
|
72 | ||
73 | return function_exists("xattr_supported") && xattr_supported($folder); |
|
74 | ||
75 | } |
|
76 | ||
77 | } |
|
78 |