Skip to content

Commit

Permalink
fix: set default TTL for APCu cache as per docs
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jul 10, 2024
1 parent 8b3055c commit 7231ef5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/private/Memcache/APCu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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

Expand Down
2 changes: 2 additions & 0 deletions lib/public/ICache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* @since 6.0.0
*/
interface ICache {
const DEFAULT_TTL = 24 * 60 * 60;

Check failure on line 18 in lib/public/ICache.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

InvalidDocblock

lib/public/ICache.php:18:2: InvalidDocblock: PHPDoc is required for constants in OCP. (see https://psalm.dev/008)

Check failure

Code scanning / Psalm

AmbiguousConstantInheritance Error

Ambiguous inheritance of OC\Memcache\LoggerWrapperCache::DEFAULT_TTL from OCP\IMemcache and OC\Memcache\Cache

Check failure on line 18 in lib/public/ICache.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

AmbiguousConstantInheritance

lib/public/ICache.php:18:8: AmbiguousConstantInheritance: Ambiguous inheritance of OC\Memcache\LoggerWrapperCache::DEFAULT_TTL from OCP\IMemcache and OC\Memcache\Cache (see https://psalm.dev/305)

/**
* Get a value from the user cache
* @param string $key
Expand Down

0 comments on commit 7231ef5

Please sign in to comment.