async delCache(key: string) { return await this.client.del(key); }
async function destroy() { subscriber.disconnect() publisher.disconnect() }
function publishObject(channel, message) { return publisher.publish(channel, JSON.stringify(message)) }
async function healthCheck() { try { await Promise.all([ // check first if not connected yet (lazy connect) subscriber.status === 'wait' ? Promise.resolve() : subscriber.ping(), publisher.status === 'wait' ? Promise.resolve() : publisher.ping() ]) } catch (err) { const error = new Error('One or more client status are not healthy') error.status = { subscriber: subscriber.status, publisher: publisher.status } throw error } }