Authored by shijian

超时时间

... ... @@ -6,11 +6,23 @@ module.exports = (type, query, req) => {
query = type === 'url' ? md5(query) : query;
if (redis && _.get(req.app.locals.pc, 'ci.tdk', false)) {
return redis.multi([
let arr = [];
arr.push(redis.multi([
['exists', `tdk:${type}:${query}`],
['hmget', `tdk:${type}:${query}`, 'key', 'title', 'keywords', 'description']
]).execAsync().then(function(res) {
return res[1];
]).execAsync());
arr.push(new Promise((resolve)=>{
setTimeout(resolve, 500, []);
}));
return Promise.race(arr).then(function(res) {
if (res.length) {
return res[1];
} else {
return [];
}
});
} else {
return Promise.resolve([]);
... ...