Skip to content

Commit ad4ac95

Browse files
committed
Fixed #893 // getItemsByTag() - empty after one item has expired
1 parent 5bd58cb commit ad4ac95

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 8.1.4
2+
#### _"Masks fell, for good.."_
3+
##### 12 february 2023
4+
- __Core__
5+
- Fixed #893 // getItemsByTag() - empty after one item has expired
6+
17
## 8.1.3
28
#### _"Don't throw the masks, yet."_
39
##### 25 may 2022

lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,17 @@ protected function driverWriteTags(ExtendedCacheItemInterface $item): bool
361361
* that has slow performances
362362
*/
363363

364-
$tagsItem->set(\array_merge((array)$data, [$item->getKey() => $expTimestamp]))
365-
->expiresAt($item->getExpirationDate());
364+
$data = \array_merge((array)$data, [$item->getKey() => $expTimestamp]);
365+
$tagsItem->set($data);
366+
367+
/**
368+
* Recalculate the expiration date
369+
*
370+
* If the $tagsItem does not have
371+
* any cache item references left
372+
* then remove it from tagsItems index
373+
*/
374+
$tagsItem->expiresAt((new DateTime())->setTimestamp(max($data)));
366375

367376
$this->driverWrite($tagsItem);
368377
$tagsItem->setHit(true);

0 commit comments

Comments
 (0)