Redis expiration 1 day

This commit is contained in:
2023-10-19 21:49:57 -03:00
parent dc217d876a
commit e536f0f8f3

View File

@ -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);
}
}