Files
marianek.pl/autoload/class.RedisConnection.php
2024-10-25 23:02:37 +02:00

30 lines
702 B
PHP

<?
class RedisConnection {
private static $instance = null;
private $redis;
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.");
}
// Autentykacja za pomocą hasła
if ( !$this -> redis -> auth( $config['redis']['password'] ) ) {
}
}
public static function getInstance() {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
}
public function getConnection() {
return $this->redis;
}
}