...
|
...
|
@@ -3,6 +3,7 @@ const _ = require('lodash'); |
|
|
const redis = require('redis');
|
|
|
const bluebird = require('bluebird');
|
|
|
const config = require('../config/common');
|
|
|
const monitor = global.yoho.monitorSender;
|
|
|
let client;
|
|
|
const timeout = 200; // redis 操作超时时间
|
|
|
|
...
|
...
|
@@ -12,6 +13,8 @@ try { |
|
|
bluebird.promisifyAll(redis.RedisClient.prototype);
|
|
|
bluebird.promisifyAll(redis.Multi.prototype);
|
|
|
|
|
|
const monitorType = _.get(monitor, 'type.REDIS');
|
|
|
|
|
|
client.all = args => {
|
|
|
if (!client.ready) {
|
|
|
if (Array.isArray(args)) {
|
...
|
...
|
@@ -21,7 +24,11 @@ try { |
|
|
}
|
|
|
}
|
|
|
|
|
|
return client.multi.call(client, args).execAsync().timeout(timeout).catch(()=>{
|
|
|
return client.multi.call(client, args).execAsync().timeout(timeout).then(res => {
|
|
|
monitor && monitor.tallySuccess(monitorType);
|
|
|
return res;
|
|
|
}).catch((e)=>{
|
|
|
monitor && monitor.tallyFail(monitorType, e);
|
|
|
return false;
|
|
|
});
|
|
|
};
|
...
|
...
|
|