Fix unable to connect to redis socket

If second argument is given, the connection is always parsed as TCP host.
This commit is contained in:
Rick van der Zwet 2020-05-25 11:58:36 +00:00
parent 82fd967b2b
commit 899185f906

View file

@ -8,8 +8,13 @@ class MemWrapper {
function __construct() {
$this->redis = new Redis();
$this->redis->connect(getConfig("redis_host"), getConfig("redis_port"))
or die ("Server could not connect to Redis!\n");
if(substr(getConfig("redis_host"), 0, 1) === "/") {
$this->redis->connect(getConfig("redis_host"))
or die ("Server could not connect to Redis socket!\n");
} else {
$this->redis->connect(getConfig("redis_host"), getConfig("redis_port"))
or die ("Server could not connect to Redis!\n");
}
if (getConfig("redis_use_auth")) {
$this->redis->auth(getConfig("redis_auth"))
or die("Incorrect Redis authentication!");