You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
This also improves the performance for multi / batch commands a lot. The reason is that now there are only callbacks internally even if a promise is going to be returned in the end.
35 lines
636 B
JavaScript
35 lines
636 B
JavaScript
'use strict'
|
|
|
|
// helpers for configuring a redis client in
|
|
// its various modes, ipV6, ipV4, socket.
|
|
const redis = require('../../index')
|
|
|
|
const config = {
|
|
redis,
|
|
Redis: redis,
|
|
PORT: 6379,
|
|
HOST: {
|
|
IPv4: '127.0.0.1',
|
|
IPv6: '::1'
|
|
},
|
|
configureClient(ip, opts) {
|
|
const args = []
|
|
// Do not manipulate the opts => copy them each time
|
|
opts = opts ? JSON.parse(JSON.stringify(opts)) : {}
|
|
|
|
if (ip.match(/\.sock/)) {
|
|
args.push(ip)
|
|
} else {
|
|
args.push(config.PORT)
|
|
args.push(config.HOST[ip])
|
|
opts.family = ip
|
|
}
|
|
|
|
args.push(opts)
|
|
|
|
return args
|
|
}
|
|
}
|
|
|
|
module.exports = config
|