Dodaj obsługę punktów Orlen w zamówieniach oraz popraw styl i logikę w szablonach
This commit is contained in:
@@ -1,30 +1,53 @@
|
||||
<?
|
||||
class RedisConnection {
|
||||
<?php
|
||||
class RedisConnection
|
||||
{
|
||||
private static $instance = null;
|
||||
private $redis;
|
||||
|
||||
private function __construct() {
|
||||
private function __construct()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$this -> redis = new \Redis();
|
||||
if ( !$this -> redis -> connect( $config['redis']['host'], $config['redis']['port'] ) ) {
|
||||
throw new Exception("Nie udało się połączyć z serwerem Redis.");
|
||||
$this->redis = new \Redis();
|
||||
|
||||
try
|
||||
{
|
||||
// Próba połączenia z serwerem Redis
|
||||
if (!$this->redis->connect($config['redis']['host'], $config['redis']['port']))
|
||||
{
|
||||
// Logowanie błędu bez rzucania wyjątku
|
||||
error_log("Nie udało się połączyć z serwerem Redis.");
|
||||
$this->redis = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Autentykacja za pomocą hasła
|
||||
if ( !$this -> redis -> auth( $config['redis']['password'] ) ) {
|
||||
|
||||
// Próba autoryzacji
|
||||
if (!$this->redis->auth($config['redis']['password']))
|
||||
{
|
||||
error_log("Autoryzacja do serwera Redis nie powiodła się.");
|
||||
$this->redis = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// Obsługa wyjątków, bez rzucania błędu
|
||||
error_log("Błąd podczas połączenia z Redis: " . $e->getMessage());
|
||||
$this->redis = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
if ( self::$instance === null ) {
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance === null)
|
||||
{
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function getConnection() {
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->redis;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user