Skip to content

Commit 162b4e8

Browse files
committed
improve cache
1 parent fd51778 commit 162b4e8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ docs
66
*~
77
build
88
.idea
9+
.php_cs.cache

src/Cache.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function set($key, $value, $ttl = null)
169169
*/
170170
private function getExpireAt($ttl): int
171171
{
172+
$ttl = $ttl ?? self::CACHE_TTL;
172173
if (is_int($ttl)) {
173174
return time() + $ttl;
174175
}
@@ -177,10 +178,6 @@ private function getExpireAt($ttl): int
177178
return date_create_immutable('@'.time())->add($ttl)->getTimestamp();
178179
}
179180

180-
if (null === $ttl) {
181-
return time() + self::CACHE_TTL;
182-
}
183-
184181
throw new CacheException(sprintf('Expected TTL to be an int, a DateInterval or null; received "%s"', is_object($ttl) ? get_class($ttl) : gettype($ttl)));
185182
}
186183

0 commit comments

Comments
 (0)