Skip to content

Commit b2fdae8

Browse files
committed
refactoring WIP
1 parent d22bae9 commit b2fdae8

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/Bridges/Psr/PsrCacheAdapter.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,10 @@ public function has(string $key): bool
100100
private static function ttlToSeconds(null|int|DateInterval $ttl = null): ?int
101101
{
102102
if ($ttl instanceof DateInterval) {
103-
return self::dateIntervalToSeconds($ttl);
103+
$now = new \DateTimeImmutable;
104+
return $now->add($ttl)->getTimestamp() - $now->getTimestamp();
104105
}
105106

106107
return $ttl;
107108
}
108-
109-
110-
private static function dateIntervalToSeconds(DateInterval $dateInterval): int
111-
{
112-
$now = new \DateTimeImmutable;
113-
$expiresAt = $now->add($dateInterval);
114-
return $expiresAt->getTimestamp() - $now->getTimestamp();
115-
}
116109
}

src/Caching/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private function completeDependencies(?array $dp): array
260260
{
261261
// convert expire into relative amount of seconds
262262
if (isset($dp[self::Expire])) {
263-
$dp[self::Expire] = Nette\Utils\DateTime::from($dp[self::Expire])->format('U') - time();
263+
$dp[self::Expire] = Nette\Utils\DateTime::from($dp[self::Expire])->getTimestamp() - time(); // TODO: tady musíme pořítat s DateTime?
264264
}
265265

266266
// make list from TAGS

0 commit comments

Comments
 (0)