Skip to content

Commit b7c85c4

Browse files
committed
Fix expires interval type
1 parent 1d6687d commit b7c85c4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/cache/src/CachePool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,12 @@ public function withDefaultTtl(DateInterval|string|int|null $defaultTtl): static
795795

796796
public function touch(string $key, DateInterval|int|string|null $ttl = null): bool
797797
{
798+
$ttl ??= $this->defaultTtl;
799+
$ttl = static::normalizeTtl($ttl);
800+
798801
if ($this->storage instanceof TouchableStorageInterface) {
799802
$item = CacheItem::create($key);
800-
$item->expiresAfter($ttl ?? $this->defaultTtl);
803+
$item->expiresAfter($ttl);
801804

802805
$expiration = $item->getExpiration()->getTimestamp();
803806

@@ -814,7 +817,7 @@ public function touch(string $key, DateInterval|int|string|null $ttl = null): bo
814817
return false;
815818
}
816819

817-
$item->expiresAfter($ttl ?? $this->defaultTtl);
820+
$item->expiresAfter($ttl);
818821

819822
return $this->save($item);
820823
}

0 commit comments

Comments
 (0)