Set blog cache to 24 hours

This commit is contained in:
grandeljay 2022-06-12 11:07:10 +02:00
parent 8a52ba31c8
commit 49972401e7
2 changed files with 4 additions and 7 deletions

View file

@ -24,6 +24,7 @@ class Blog extends Cache
parent::__construct($url);
$this->directory .= '/blog';
$this->maxAge = 86400; // 24 hours
}
public function get(): \stdClass|array

View file

@ -11,20 +11,16 @@ class Cache
/**
* Private
*/
private function age(): int
private function getAge(): int
{
return time() - filemtime($this->getFilepath());
}
private function maxAge(): int
{
return 2592000; // 30 days
}
/**
* Protected
*/
protected string $directory = ROOT . '/src/cache';
protected int $maxAge = 2592000; // 30 days
protected function getIdentifier(): string
{
@ -63,6 +59,6 @@ class Cache
public function generateCache(): bool
{
return !$this->exists()
|| ($this->exists() && $this->age() > $this->maxAge());
|| ($this->exists() && $this->getAge() > $this->maxAge);
}
}