Skip to content

Commit f51a116

Browse files
rvanlaakNyholm
authored andcommitted
allow CachePool to set ttl via CacheItem callable
1 parent 65a5f87 commit f51a116

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

FilesystemCachePool.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ protected function fetchObjectFromCache($key)
7878
return $empty;
7979
}
8080

81-
if ($data[0] !== null && time() > $data[0]) {
81+
// Determine ttl from data, remove items if expired
82+
$ttl = $data[0] ?: null;
83+
if ($ttl !== null && time() > $ttl) {
8284
foreach ($data[2] as $tag) {
8385
$this->removeListItem($this->getTagKey($tag), $key);
8486
}
@@ -87,7 +89,7 @@ protected function fetchObjectFromCache($key)
8789
return $empty;
8890
}
8991

90-
return [true, $data[1], $data[2]];
92+
return [true, $data[1], $data[2], $ttl];
9193
}
9294

9395
/**

0 commit comments

Comments
 (0)