aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-08-07 20:16:02 +0200
committerGitHub <noreply@github.com>2024-08-07 20:16:02 +0200
commit495f454b6f04cc6ee7ce1410dd9a9f1926a0b1ee (patch)
treeebce90f045ca876ff113f5edfa10e4c8d757207c /lib/private
parenta46e0a74050bc057d26cb39d2c3b857663d41664 (diff)
parent5490b12febf6ac2b93d320ed5521b272faa6f73a (diff)
downloadnextcloud-server-495f454b6f04cc6ee7ce1410dd9a9f1926a0b1ee.tar.gz
nextcloud-server-495f454b6f04cc6ee7ce1410dd9a9f1926a0b1ee.zip
Merge pull request #46395 from nextcloud/apcu-default-ttl
fix: set default TTL for APCu cache as per docs
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Memcache/APCu.php36
-rw-r--r--lib/private/Memcache/Redis.php1
2 files changed, 8 insertions, 29 deletions
diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php
index 7f6a73354ee..024462d227b 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);
}
@@ -67,22 +73,8 @@ class APCu extends Cache implements IMemcache {
* @return int | bool
*/
public function inc($key, $step = 1) {
- $this->add($key, 0);
- /**
- * TODO - hack around a PHP 7 specific issue in APCu
- *
- * on PHP 7 the apcu_inc method on a non-existing object will increment
- * "0" and result in "1" as value - therefore we check for existence
- * first
- *
- * on PHP 5.6 this is not the case
- *
- * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
- * for details
- */
- return apcu_exists($this->getPrefix() . $key)
- ? apcu_inc($this->getPrefix() . $key, $step)
- : false;
+ $success = null;
+ return apcu_inc($this->getPrefix() . $key, $step, $success, self::DEFAULT_TTL);
}
/**
@@ -93,18 +85,6 @@ class APCu extends Cache implements IMemcache {
* @return int | bool
*/
public function dec($key, $step = 1) {
- /**
- * TODO - hack around a PHP 7 specific issue in APCu
- *
- * on PHP 7 the apcu_dec method on a non-existing object will decrement
- * "0" and result in "-1" as value - therefore we check for existence
- * first
- *
- * on PHP 5.6 this is not the case
- *
- * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
- * for details
- */
return apcu_exists($this->getPrefix() . $key)
? apcu_dec($this->getPrefix() . $key, $step)
: false;
diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php
index cbafadc3b1b..87dc86ab10d 100644
--- a/lib/private/Memcache/Redis.php
+++ b/lib/private/Memcache/Redis.php
@@ -29,7 +29,6 @@ class Redis extends Cache implements IMemcacheTTL {
],
];
- private const DEFAULT_TTL = 24 * 60 * 60; // 1 day
private const MAX_TTL = 30 * 24 * 60 * 60; // 1 month
/**