feat: add filecache config to enable/disable real purge (#3263)

* refactor: cachefactory

* feat: add filecache config to enable/disable real purge

* test: fix test
This commit is contained in:
Dag 2023-03-06 21:50:40 +01:00 committed by GitHub
parent 007f2b2d8a
commit 058e792b8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 12 deletions

View file

@ -2,11 +2,13 @@
class FileCache implements CacheInterface
{
private array $config;
protected $path;
protected $key;
public function __construct()
public function __construct(array $config = [])
{
$this->config = $config;
if (!is_writable(PATH_CACHE)) {
throw new \Exception('The cache folder is not writeable');
}
@ -46,6 +48,10 @@ class FileCache implements CacheInterface
public function purgeCache($seconds)
{
if (! $this->config['enable_purge']) {
return;
}
$cachePath = $this->getPath();
if (!file_exists($cachePath)) {
return;