diff --git a/keyserver/src/socket/redis.js b/keyserver/src/socket/redis.js --- a/keyserver/src/socket/redis.js +++ b/keyserver/src/socket/redis.js @@ -31,10 +31,13 @@ })(); class RedisPublisher { - pub: RedisClient; + client: ?RedisClient; - constructor() { - this.pub = redis.createClient(redisConfig); + get pub(): RedisClient { + if (!this.client) { + this.client = redis.createClient(redisConfig); + } + return this.client; } sendMessage(target: UpdateTarget, message: RedisMessage) { @@ -49,7 +52,7 @@ } end() { - this.pub.unref(); + this.client?.unref(); } } const publisher: RedisPublisher = new RedisPublisher();