mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-23 09:13:07 +01:00
Rename FilesCache::isValid()
to FilesCache::hasExpired()
This commit is contained in:
parent
9131747153
commit
de1dbdc3cf
@ -42,7 +42,7 @@ class FilesCache extends AbstractCache
|
||||
$data = PHP::parseFile($this->getFile($key));
|
||||
return $data['value'];
|
||||
}
|
||||
if (!$this->isValid($key)) {
|
||||
if ($this->hasExpired($key)) {
|
||||
FileSystem::delete($this->getFile($key));
|
||||
}
|
||||
return null;
|
||||
@ -81,7 +81,7 @@ class FilesCache extends AbstractCache
|
||||
*/
|
||||
public function has(string $key): bool
|
||||
{
|
||||
return FileSystem::exists($this->getFile($key)) && $this->isValid($key);
|
||||
return FileSystem::exists($this->getFile($key)) && !$this->hasExpired($key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,9 +95,9 @@ class FilesCache extends AbstractCache
|
||||
/**
|
||||
* Return whether a cached resource has not expired
|
||||
*/
|
||||
protected function isValid(string $key): bool
|
||||
protected function hasExpired(string $key): bool
|
||||
{
|
||||
$data = PHP::parseFile($this->getFile($key));
|
||||
return time() < $data['expires'];
|
||||
return time() >= $data['expires'];
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,12 @@ class SiteCache extends FilesCache
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function isValid(string $key): bool
|
||||
protected function hasExpired(string $key): bool
|
||||
{
|
||||
if (parent::hasExpired($key)) {
|
||||
return true;
|
||||
}
|
||||
$lastModified = FileSystem::lastModifiedTime($this->getFile($key));
|
||||
return parent::isValid($key) && !Formwork::instance()->site()->modifiedSince($lastModified);
|
||||
return Formwork::instance()->site()->modifiedSince($lastModified);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user