Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: set default TTL for APCu cache as per docs
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Aug 7, 2024
commit cd9cc01b7739535cc9246103f90ae2d02d8ea217
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
*/
public const DEFAULT_TTL = 24 * 60 * 60;

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