diff options
Diffstat (limited to 'lib/CacheFactory.php')
-rw-r--r-- | lib/CacheFactory.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CacheFactory.php b/lib/CacheFactory.php index abafa3ba..78a0e83e 100644 --- a/lib/CacheFactory.php +++ b/lib/CacheFactory.php @@ -51,7 +51,26 @@ class CacheFactory } return new FileCache($fileCacheConfig); case SQLiteCache::class: - return new SQLiteCache(); + if (!extension_loaded('sqlite3')) { + throw new \Exception('"sqlite3" extension not loaded. Please check "php.ini"'); + } + if (!is_writable(PATH_CACHE)) { + throw new \Exception('The cache folder is not writable'); + } + $file = Configuration::getConfig('SQLiteCache', 'file'); + if (!$file) { + throw new \Exception(sprintf('Configuration for %s missing.', 'SQLiteCache')); + } + if (dirname($file) == '.') { + $file = PATH_CACHE . $file; + } elseif (!is_dir(dirname($file))) { + throw new \Exception(sprintf('Invalid configuration for %s', 'SQLiteCache')); + } + return new SQLiteCache([ + 'file' => $file, + 'timeout' => Configuration::getConfig('SQLiteCache', 'timeout'), + 'enable_purge' => Configuration::getConfig('SQLiteCache', 'enable_purge'), + ]); case MemcachedCache::class: return new MemcachedCache(); default: |