2019-12-12 13:58:58 +03:00
|
|
|
const { redisUrl } = require('../config')
|
|
|
|
const Redis = require('ioredis')
|
|
|
|
const redisClient = new Redis(redisUrl)
|
|
|
|
const subscriber = new Redis(redisUrl)
|
|
|
|
|
|
|
|
const redisOpts = {
|
|
|
|
createClient: function (type) {
|
|
|
|
switch (type) {
|
|
|
|
case 'client':
|
|
|
|
return redisClient
|
|
|
|
case 'subscriber':
|
|
|
|
return subscriber
|
|
|
|
default:
|
|
|
|
return new Redis(redisUrl)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 10:39:56 +03:00
|
|
|
module.exports = { redisOpts, redisClient }
|