From cb6509d09dd4995147dcdb3ef14531cc2b3a3491 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 25 Sep 2020 07:26:30 +0200 Subject: [PATCH] Cache for 365 days if $ttl not set --- system/libs/cache_file.php | 9 ++++----- system/libs/cache_php.php | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/system/libs/cache_file.php b/system/libs/cache_file.php index 13e34ef8..a4c897c8 100644 --- a/system/libs/cache_file.php +++ b/system/libs/cache_file.php @@ -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) diff --git a/system/libs/cache_php.php b/system/libs/cache_php.php index e7c2bb5e..5d35ceef 100644 --- a/system/libs/cache_php.php +++ b/system/libs/cache_php.php @@ -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)