20 lines
478 B
PHP
20 lines
478 B
PHP
<?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;
|
|
}
|
|
}
|