From 7231ef51e0f3e2ce2cf1ae52f431e342a3f5c7e6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 10 Jul 2024 12:42:46 +0200 Subject: [PATCH] fix: set default TTL for APCu cache as per docs Signed-off-by: Robin Appelman --- lib/private/Memcache/APCu.php | 6 ++++++ lib/public/ICache.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php index 7f6a73354eed1..9eb2ee0b2bf14 100644 --- a/lib/private/Memcache/APCu.php +++ b/lib/private/Memcache/APCu.php @@ -25,6 +25,9 @@ public function get($key) { } public function set($key, $value, $ttl = 0) { + if ($ttl === 0) { + $ttl = self::DEFAULT_TTL; + } return apcu_store($this->getPrefix() . $key, $value, $ttl); } @@ -56,6 +59,9 @@ public function clear($prefix = '') { * @return bool */ public function add($key, $value, $ttl = 0) { + if ($ttl === 0) { + $ttl = self::DEFAULT_TTL; + } return apcu_add($this->getPrefix() . $key, $value, $ttl); } diff --git a/lib/public/ICache.php b/lib/public/ICache.php index ba6016c8d283b..d191fcb8a071d 100644 --- a/lib/public/ICache.php +++ b/lib/public/ICache.php @@ -15,6 +15,8 @@ * @since 6.0.0 */ interface ICache { + const DEFAULT_TTL = 24 * 60 * 60; + /** * Get a value from the user cache * @param string $key