1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-21 23:28:48 -05:00

Add support for unix socket connection to redis

This commit is contained in:
Travis Burtrum 2017-02-05 23:55:29 -05:00
parent f2f9a92351
commit a61a2a5aae

View File

@ -44,7 +44,8 @@ Database_Redis::Database_Redis(Settings &conf)
} }
const char *addr = tmp.c_str(); const char *addr = tmp.c_str();
int port = conf.exists("redis_port") ? conf.getU16("redis_port") : 6379; int port = conf.exists("redis_port") ? conf.getU16("redis_port") : 6379;
ctx = redisConnect(addr, port); // if redis_address contains '/' assume unix socket, else hostname/ip
ctx = tmp.find('/') != std::string::npos ? redisConnectUnix(addr) : redisConnect(addr, port);
if (!ctx) { if (!ctx) {
throw DatabaseException("Cannot allocate redis context"); throw DatabaseException("Cannot allocate redis context");
} else if (ctx->err) { } else if (ctx->err) {