Delete invalid cached resources when fetching with FilesCache::fetch()

This commit is contained in:
Giuseppe Criscione 2019-03-16 21:38:29 +01:00
parent f695701540
commit e60e30619d

View File

@ -40,9 +40,12 @@ class FilesCache extends AbstractCache
*/
public function fetch($key)
{
if ($this->has($key) && $this->isValid($key)) {
$data = FileSystem::read($this->getFile($key));
return unserialize($data);
if ($this->has($key)) {
if ($this->isValid($key)) {
$data = FileSystem::read($this->getFile($key));
return unserialize($data);
}
FileSystem::delete($this->getFile($key));
}
return null;
}