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; } // 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) { self::$instance = new self(); } return self::$instance; } public function getConnection() { return $this->redis; } }