Browse Source

redis.Cluster

release_0.0.2
巴林闲侠 2 years ago
parent
commit
df40d3d9df
  1. 17
      code/VideoAccess-VCMP/api/app/lib/service/redis.js

17
code/VideoAccess-VCMP/api/app/lib/service/redis.js

@ -3,9 +3,20 @@
const redis = require("ioredis")
module.exports = async function factory (app, opts) {
let client = new redis(opts.redis.port, opts.redis.host, {
password: opts.redis.pwd,
});
let client = opts.redis.pwd ?
new redis.Cluster([
{
host: opts.redis.host,
port: opts.redis.port
}
], {
redisOptions: {
password: opts.redis.pwd,
},
})
: new redis(opts.redis.port, opts.redis.host, {
password: opts.redis.pwd,
});
client.on("error", function (err) {
app.fs.logger.error('info', '[FS-AUTH-REDIS]', `redis connect error. ${opts.redis.host + ':' + opts.redis.port}`);

Loading…
Cancel
Save