From 8059d01bead308159ce6ab1a46989cf8d2d3dd2f Mon Sep 17 00:00:00 2001 From: Golban Sergiu Date: Wed, 27 Dec 2017 12:36:12 +0200 Subject: [PATCH 1/2] add TTL to PSR16 storage implementation --- src/Storage/Psr16CacheStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Psr16CacheStorage.php b/src/Storage/Psr16CacheStorage.php index 2d4b8e56..208b0fe2 100644 --- a/src/Storage/Psr16CacheStorage.php +++ b/src/Storage/Psr16CacheStorage.php @@ -35,7 +35,7 @@ public function fetch($key) */ public function save($key, CacheEntry $data) { - $this->cache->set($key, $data); + $this->cache->set($key, $data, $data->getTTL()); } /** From 995498217b19c04df50fafcb53e09c10a5cf417a Mon Sep 17 00:00:00 2001 From: Golban Sergiu Date: Wed, 10 Jan 2018 15:25:16 +0200 Subject: [PATCH 2/2] handle default ttl --- src/Storage/Psr16CacheStorage.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Storage/Psr16CacheStorage.php b/src/Storage/Psr16CacheStorage.php index 208b0fe2..83782200 100644 --- a/src/Storage/Psr16CacheStorage.php +++ b/src/Storage/Psr16CacheStorage.php @@ -35,7 +35,11 @@ public function fetch($key) */ public function save($key, CacheEntry $data) { - $this->cache->set($key, $data, $data->getTTL()); + $ttl = $data->getTTL(); + if ($ttl === 0) { + return $this->cache->set($key, $data); + } + return $this->cache->set($key, $data, $data->getTTL()); } /**