soselo/classes/RedisDatabase.php

20 lines
478 B
PHP
Raw Normal View History

2022-12-12 12:51:20 +00:00
<?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;
}
}