fix: set default TTL for APCu cache as per docs

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/46395/head
Robin Appelman 2024-07-10 12:42:46 +07:00
parent 0050e1e219
commit cd9cc01b77
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
2 changed files with 11 additions and 0 deletions

@ -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);
}

@ -15,6 +15,11 @@ namespace OCP;
* @since 6.0.0
*/
interface ICache {
/**
* @since 30.0.0
*/
public const DEFAULT_TTL = 24 * 60 * 60;
/**
* Get a value from the user cache
* @param string $key