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 8a5ecb3
Show file tree
Hide file tree
Showing 2 changed files with 11 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
5 changes: 5 additions & 0 deletions lib/public/ICache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* @since 6.0.0
*/
interface ICache {
/**
* @since 30.0.0
*/
const DEFAULT_TTL = 24 * 60 * 60;

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

0 comments on commit 8a5ecb3

Please sign in to comment.