1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-06-25 20:34:22 +02:00

feat(sqlite cache): add config options (#3499)

* refactor: sqlite cache

* refactor

* feat: add config options to sqlite cache

* refactor
This commit is contained in:
Dag
2023-07-06 15:59:38 +02:00
committed by GitHub
parent 21c8d8775e
commit 965d7d44c5
4 changed files with 69 additions and 54 deletions

View File

@ -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: