From c623297ca0c55965fb861eef115a24184e6d7657 Mon Sep 17 00:00:00 2001 From: Raivis Kalinins Date: Mon, 14 May 2018 12:11:30 +0300 Subject: [PATCH] Prevent decoding if redis returns null (key does not exist) --- src/Spiritix/LadaCache/Cache.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Spiritix/LadaCache/Cache.php b/src/Spiritix/LadaCache/Cache.php index c40a1dc..02faaa7 100644 --- a/src/Spiritix/LadaCache/Cache.php +++ b/src/Spiritix/LadaCache/Cache.php @@ -105,6 +105,11 @@ public function get($key) { $encoded = $this->redis->get($this->redis->prefix($key)); + // Prevent decoding if redis returns null (key does not exist). + if ($encoded === null) { + return null; + } + return $this->encoder->decode($encoded); }