const redis = require('thunk-redis') import * as config from 'config' const ilog = require('ilog') const getClient = (usePromise = false) => redis .createClient(config.REDIS.REDIS_ARRAY, { usePromise: true }) .on('error', function (err) { err.class = 'thunk-redis' ilog.error(err) if (err.code === 'ENETUNREACH') { throw err } }) .on('close', function (err) { if (!err) { err = new Error('Redis client closed!') } err.class = 'thunk-redis' ilog.error(err) throw err }) const client = getClient() module.exports = client