diff options
Diffstat (limited to 'lib/CacheFactory.php')
-rw-r--r-- | lib/CacheFactory.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CacheFactory.php b/lib/CacheFactory.php index 3f076d83..df78d9cb 100644 --- a/lib/CacheFactory.php +++ b/lib/CacheFactory.php @@ -4,6 +4,14 @@ declare(strict_types=1); class CacheFactory { + private Logger $logger; + + public function __construct( + Logger $logger + ) { + $this->logger = $logger; + } + public function create(string $name = null): CacheInterface { $name ??= Configuration::getConfig('cache', 'type'); @@ -49,7 +57,7 @@ class CacheFactory if (!is_writable($fileCacheConfig['path'])) { throw new \Exception(sprintf('The FileCache path is not writable: %s', $fileCacheConfig['path'])); } - return new FileCache($fileCacheConfig); + return new FileCache($this->logger, $fileCacheConfig); case SQLiteCache::class: if (!extension_loaded('sqlite3')) { throw new \Exception('"sqlite3" extension not loaded. Please check "php.ini"'); @@ -66,7 +74,7 @@ class CacheFactory } elseif (!is_dir(dirname($file))) { throw new \Exception(sprintf('Invalid configuration for %s', 'SQLiteCache')); } - return new SQLiteCache([ + return new SQLiteCache($this->logger, [ 'file' => $file, 'timeout' => Configuration::getConfig('SQLiteCache', 'timeout'), 'enable_purge' => Configuration::getConfig('SQLiteCache', 'enable_purge'), @@ -94,7 +102,7 @@ class CacheFactory if ($port < 1 || $port > 65535) { throw new \Exception('"port" param is invalid for ' . $section); } - return new MemcachedCache($host, $port); + return new MemcachedCache($this->logger, $host, $port); default: if (!file_exists(PATH_LIB_CACHES . $className . '.php')) { throw new \Exception('Unable to find the cache file'); |