Added RedisDatabase class
This commit is contained in:
parent
dd92256817
commit
5c2d180312
1
base.php
1
base.php
|
@ -495,3 +495,4 @@ function cronjob_db_create($software, $instance, $sql, $time=3600) {
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
require 'classes/PgDatabase.php';
|
require 'classes/PgDatabase.php';
|
||||||
|
require 'classes/RedisDatabase.php';
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class RedisDatabase extends Redis {
|
||||||
|
|
||||||
|
public function __construct($software, $instance) {
|
||||||
|
$config = instance_config($software, $instance);
|
||||||
|
try {
|
||||||
|
$this->connect($config['redis_host'], $config['redis_port']);
|
||||||
|
if (isset($config['redis_password']))
|
||||||
|
$this->auth($config['redis_password']);
|
||||||
|
} catch (RedisException $e) {
|
||||||
|
return apiresult(['error' => 'Could not connect to Redis: '.strval($e)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->ping())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue