aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-07-10 12:42:46 +0200
committerRobin Appelman <robin@icewind.nl>2024-08-07 19:41:41 +0200
commitcd9cc01b7739535cc9246103f90ae2d02d8ea217 (patch)
tree6fbbc9cdce6182ed130ef4ebcc40afa7c819f19c
parent0050e1e2199bc0b99dcd9a03ed55e850cc323ce2 (diff)
downloadnextcloud-server-cd9cc01b7739535cc9246103f90ae2d02d8ea217.tar.gz
nextcloud-server-cd9cc01b7739535cc9246103f90ae2d02d8ea217.zip
fix: set default TTL for APCu cache as per docs
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Memcache/APCu.php6
-rw-r--r--lib/public/ICache.php5
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php
index 7f6a73354ee..9eb2ee0b2bf 100644
--- a/lib/private/Memcache/APCu.php
+++ b/lib/private/Memcache/APCu.php
@@ -25,6 +25,9 @@ class APCu extends Cache implements IMemcache {
}
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 @@ class APCu extends Cache implements IMemcache {
* @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 ba6016c8d28..5e755d81e14 100644
--- a/lib/public/ICache.php
+++ b/lib/public/ICache.php
@@ -16,6 +16,11 @@ namespace OCP;
*/
interface ICache {
/**
+ * @since 30.0.0
+ */
+ public const DEFAULT_TTL = 24 * 60 * 60;
+
+ /**
* Get a value from the user cache
* @param string $key
* @return mixed