From c7f8f90596c079af6a2b752660d746a2939059db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kel=C4=8D=C3=A1k?= Date: Wed, 18 Jan 2023 17:47:47 +0100 Subject: [PATCH] Fix ttl in filecache, v2.4.6 --- src/Cache.php | 2 +- src/Storages/FileStorage.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Cache.php b/src/Cache.php index ca20367..f07df91 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -13,7 +13,7 @@ namespace RobiNN\Cache; class Cache { - final public const VERSION = '2.4.5'; + final public const VERSION = '2.4.6'; private readonly CacheInterface $cache; diff --git a/src/Storages/FileStorage.php b/src/Storages/FileStorage.php index 5b39647..5c7e4ef 100644 --- a/src/Storages/FileStorage.php +++ b/src/Storages/FileStorage.php @@ -87,6 +87,10 @@ public function get(string $key): mixed { public function ttl(string $key): int { $data = $this->getRaw($key); + if ($data['expire'] === 0) { + return 0; + } + return $data['time'] + $data['expire'] - time(); }