Set blog cache to 24 hours
This commit is contained in:
parent
8a52ba31c8
commit
49972401e7
2 changed files with 4 additions and 7 deletions
1
src/classes/cache/blog.php
vendored
1
src/classes/cache/blog.php
vendored
|
@ -24,6 +24,7 @@ class Blog extends Cache
|
|||
parent::__construct($url);
|
||||
|
||||
$this->directory .= '/blog';
|
||||
$this->maxAge = 86400; // 24 hours
|
||||
}
|
||||
|
||||
public function get(): \stdClass|array
|
||||
|
|
10
src/classes/cache/cache.php
vendored
10
src/classes/cache/cache.php
vendored
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue