From e536f0f8f31808e6b46c23b56d8a3c67effdee6d Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 19 Oct 2023 21:49:57 -0300 Subject: [PATCH] Redis expiration 1 day --- app/src/Service/Redis.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/Service/Redis.php b/app/src/Service/Redis.php index 5a9845a..1d7f050 100644 --- a/app/src/Service/Redis.php +++ b/app/src/Service/Redis.php @@ -2,6 +2,7 @@ namespace Incoviba\Service; use Predis\Client; +use Incoviba\Common\Implement\Exception\EmptyRedis; class Redis { @@ -9,10 +10,13 @@ class Redis public function get(string $name): mixed { + if (!$this->client->exists($name)) { + throw new EmptyRedis($name); + } return $this->client->get($name); } public function set(string $name, mixed $value): void { - $this->client->set($name, $value); + $this->client->set($name, $value, 'EX', 60 * 60 * 24); } }