Authored by 郭成尧

redis-timeout-200

@@ -20,6 +20,7 @@ const searchProcess = require(`${utils}/search-process`); @@ -20,6 +20,7 @@ const searchProcess = require(`${utils}/search-process`);
20 const stringProcess = require(`${utils}/string-process`); 20 const stringProcess = require(`${utils}/string-process`);
21 const listParamsProcess = require(`${utils}/list-params-process`); 21 const listParamsProcess = require(`${utils}/list-params-process`);
22 const redis = require(`${utils}/redis`); 22 const redis = require(`${utils}/redis`);
  23 +const logger = global.yoho.logger;
23 24
24 /** 25 /**
25 * 封面图 26 * 封面图
@@ -325,6 +326,7 @@ const listNew = (req, res, next) => { @@ -325,6 +326,7 @@ const listNew = (req, res, next) => {
325 } 326 }
326 co(function* () { 327 co(function* () {
327 let result = yield req.ctx(searchModel).getCategoryGoods(initialData); 328 let result = yield req.ctx(searchModel).getCategoryGoods(initialData);
  329 + let categoryIntroRedis = [];
328 330
329 let responseResult = { 331 let responseResult = {
330 list: productProcess.processProductList(result.data.product_list || [], { 332 list: productProcess.processProductList(result.data.product_list || [], {
@@ -344,8 +346,13 @@ const listNew = (req, res, next) => { @@ -344,8 +346,13 @@ const listNew = (req, res, next) => {
344 seoTitle = decodeURIComponent(params.sort_name); 346 seoTitle = decodeURIComponent(params.sort_name);
345 } 347 }
346 348
347 - let categoryIntroRedis =  
348 - yield redis.hmgetAsync(`category:description:${md5(seoTitle)}`, 'category', 'description'); 349 + try {
  350 + categoryIntroRedis =
  351 + yield redis.hmgetAsync(`category:description:${md5(seoTitle)}`, 'category', 'description').timeout(200);
  352 + } catch (e) {
  353 + logger.error('redis.hmgetAsync.category.description:' + e);
  354 + }
  355 +
349 let categoryIntro = categoryIntroRedis[1] ? { 356 let categoryIntro = categoryIntroRedis[1] ? {
350 title: categoryIntroRedis[0], 357 title: categoryIntroRedis[0],
351 desc: categoryIntroRedis[1] 358 desc: categoryIntroRedis[1]