Browse Source

首页缓存修改

chenbiao 9 months ago
parent
commit
fefb01d803

+ 16 - 11
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -1062,7 +1062,7 @@ public class GoodsDonController {
 				    .orderBy(OrderCommentFrontView::getId).desc()
 				    .build());
 		    goodsDetailView.setComments(comments);
-		    redisService.setNx(yhShopDetailCacheKey, goodsDetailView, RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getTimeout() + RandomUtil.randomInt(1000));
+		    redisService.setNx(yhShopDetailCacheKey, goodsDetailView, 60 * 60 * 24L);
 		    value = redisService.get(yhShopDetailCacheKey);
 	    }
 	    YhShopGoodsFrontView goodsDetailView = Jsons.parseObject(value, YhShopGoodsFrontView.class);
@@ -1278,15 +1278,20 @@ public class GoodsDonController {
 //		}
 		Object o = redisService.get(key);
 		if (o == null) {
-			MapBuilder builder = MapUtils.builder()
-					.field(HomeManagementFrontView::getAdType, List.of(HomeManagementConfig.AdType.pc.name(), HomeManagementConfig.AdType.pcBanner.name(), HomeManagementConfig.AdType.pcSec.name(), HomeManagementConfig.AdType.pcDis.name())).op(Operator.InList);
-			if (filterConfigId != null) {
-				builder.field(HomeManagementFrontView::getHomeManageConfigId, filterConfigId).op(Operator.NotEqual);
-			}
-			List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
-			Map<HomeManagementConfig.AdType, List<HomeManagementFrontView>> map = homeManagementFrontViews.stream().collect(Collectors.groupingBy(HomeManagementFrontView::getAdType));
-			redisService.setNx(key, map, 50 * 60l);
-			o = redisService.get(key);
+			try {
+                MapBuilder builder = MapUtils.builder()
+                        .field(HomeManagementFrontView::getAdType, List.of(HomeManagementConfig.AdType.pc.name(), HomeManagementConfig.AdType.pcBanner.name(), HomeManagementConfig.AdType.pcSec.name(), HomeManagementConfig.AdType.pcDis.name())).op(Operator.InList);
+                if (filterConfigId != null) {
+                    builder.field(HomeManagementFrontView::getHomeManageConfigId, filterConfigId).op(Operator.NotEqual);
+                }
+                List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
+                Map<HomeManagementConfig.AdType, List<HomeManagementFrontView>> map = homeManagementFrontViews.stream().collect(Collectors.groupingBy(HomeManagementFrontView::getAdType));
+                redisService.setNx(key, map, 60 * 60l * 24 * 7);
+                o = redisService.get(key);
+            }catch (Exception e) {
+                redisService.setNx(key, new HashMap<HomeManagementConfig.AdType, List<HomeManagementFrontView>>(), 10L);
+                o = redisService.get(key);
+            }
 		}
 		Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(map);
@@ -1329,7 +1334,7 @@ public class GoodsDonController {
 					e.setPicture(sku.getSubsidyPicture());
 				});
 			});
-			redisService.setNx(key, subsidyList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
+			redisService.setNx(key, subsidyList, 60 * 60 * 24 * 7L);
 			o = redisService.get(key);
 		}
 		List<GoodsDonSkuSubsidyFrontView> subsidyList = Jsons.parseList(o, GoodsDonSkuSubsidyFrontView.class);

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/information/InformationController.java

@@ -54,7 +54,7 @@ public class InformationController {
         IPage<InformationListView> information  = (IPage<InformationListView>) redisService.get(key);
         if (information == null) {
             information = informationService.getInformation(categoryId, start, limit);
-            redisService.setNx(key, information, RedisService.key.INFORMATION_KEY.getTimeout() + RandomUtil.randomInt(10000));
+            redisService.setNx(key, information, 60L * 60 * 24 * 7);
         }
         return GatewayResponse.SUCCESS.newBuilder().toResult(information);
     }
@@ -72,7 +72,7 @@ public class InformationController {
             if (CollUtil.isEmpty(informationCategory)) {
                 return GatewayResponse.SUCCESS.newBuilder().toResult();
             }
-            redisService.setNx(key, informationCategory, RedisService.key.INFORMATION_KEY.getTimeout() + RandomUtil.randomInt(100000));
+            redisService.setNx(key, informationCategory, 60L * 60 * 24 * 7);
         }
         return GatewayResponse.SUCCESS.newBuilder().toResult(informationCategory);
     }