Guardar factura
This commit is contained in:
@ -3,6 +3,7 @@ namespace Incoviba\Service;
|
||||
|
||||
use Predis\ClientInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Predis\Connection\ConnectionException;
|
||||
|
||||
class Redis
|
||||
{
|
||||
@ -10,13 +11,21 @@ class Redis
|
||||
|
||||
public function get(string $name): mixed
|
||||
{
|
||||
if (!$this->client->exists($name)) {
|
||||
throw new EmptyRedis($name);
|
||||
try {
|
||||
if (!$this->client->exists($name)) {
|
||||
throw new EmptyRedis($name);
|
||||
}
|
||||
return $this->client->get($name);
|
||||
} catch (ConnectionException $exception) {
|
||||
throw new EmptyRedis($name, $exception);
|
||||
}
|
||||
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);
|
||||
try {
|
||||
$this->client->set($name, $value, 'EX', $expirationTTL);
|
||||
} catch (ConnectionException) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user