- Making sure cache file exist before invalidating; creating it if it ain't
This commit is contained in:
parent
e2915c356a
commit
ed63c1ffe5
|
@ -12,13 +12,13 @@ class CacheInvalidator
|
||||||
protected string $filePath,
|
protected string $filePath,
|
||||||
protected bool $updateVersion = false,
|
protected bool $updateVersion = false,
|
||||||
) {
|
) {
|
||||||
if ($this->updateVersion) {
|
if ($this->updateVersion || ! file_exists($this->filePath)) {
|
||||||
$this->version = $this->generateVersion();
|
$this->version = $this->generateVersion();
|
||||||
file_put_contents($this->filePath, $this->version);
|
file_put_contents($this->filePath, $this->version);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->version = file_get_contents($this->filePath);
|
$this->version = file_get_contents($this->filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateVersion() : string
|
protected function generateVersion() : string
|
||||||
|
@ -30,4 +30,4 @@ class CacheInvalidator
|
||||||
{
|
{
|
||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue