|
|
@@ -1,5 +1,5 @@
|
|
|
var redis = require("redis");
|
|
|
-var uuidv4 = require('uuid/v4');
|
|
|
+var uuidv4 = require('uuid').v4;
|
|
|
|
|
|
/**
|
|
|
* Redis存档的Hash消息管理工具
|
|
|
@@ -15,14 +15,18 @@ module.exports = function(conf)
|
|
|
*/
|
|
|
var init = () => {
|
|
|
this.conf = conf;
|
|
|
+ var socket = { host: conf.redis_host, port: conf.redis_port };
|
|
|
// noderedis密码等选项
|
|
|
- var options = conf.redis_pwd ? { password: conf.redis_pwd } : null;
|
|
|
+ var options = { legacyMode: true, password: conf.redis_pwd, socket: socket };
|
|
|
+ if (!options.password) delete options.password;
|
|
|
// redis client instance
|
|
|
- this.client = redis.createClient(conf.redis_port, conf.redis_host, options);
|
|
|
+ this.client = redis.createClient(options);
|
|
|
|
|
|
this.client.on("error", (err) => {
|
|
|
- console.log("redis Error " + err);
|
|
|
+ console.log("redis Error " + err);
|
|
|
});
|
|
|
+
|
|
|
+ return this.client.connect();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -96,4 +100,4 @@ module.exports = function(conf)
|
|
|
|
|
|
// 初始化
|
|
|
init();
|
|
|
-}
|
|
|
+}
|