<?php
namespace Incoviba\Service;

use Predis\ClientInterface;
use Incoviba\Common\Implement\Exception\EmptyRedis;

class Redis
{
    public function __construct(protected ClientInterface $client) {}

    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, int $expirationTTL = 60 * 60 * 24): void
    {
        $this->client->set($name, $value, 'EX', $expirationTTL);
    }
}
