first commit
This commit is contained in:
30
autoload/class.RedisConnection.php
Normal file
30
autoload/class.RedisConnection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user