Cache for 365 days if $ttl not set

This commit is contained in:
slawkens 2020-09-25 07:26:30 +02:00
parent f09c129c6d
commit cb6509d09d
2 changed files with 9 additions and 10 deletions

View File

@ -26,12 +26,11 @@ class Cache_File
$file = $this->_name($key);
file_put_contents($file, $var);
if($ttl !== 0) {
touch($file, time() + $ttl);
}
else {
touch($file, time() + 24 * 60 * 60);
if ($ttl === 0) {
$ttl = 365 * 24 * 60 * 60; // 365 days
}
touch($file, time() + $ttl);
}
public function get($key)

View File

@ -31,12 +31,12 @@ class Cache_PHP
$file = $this->_name($key);
rename($tmp, $file);
if($ttl !== 0) {
touch($file, time() + $ttl);
}
else {
touch($file, time() + 24 * 60 * 60);
if ($ttl === 0) {
$ttl = 365 * 24 * 60 * 60; // 365 days
}
touch($file, time() + $ttl);
}
public function get($key)