Showing
4 changed files
with
81 additions
and
4 deletions
@@ -53,8 +53,8 @@ public class BrandIndexBuilder extends IIndexBuilder { | @@ -53,8 +53,8 @@ public class BrandIndexBuilder extends IIndexBuilder { | ||
53 | 53 | ||
54 | 54 | ||
55 | public void loadData() { | 55 | public void loadData() { |
56 | - tblBrandMap = basicDataCacheService.getTblBrandRelationMap(); | ||
57 | - ufoBrandMap = basicDataCacheService.getUfoBrandRelationMap(); | 56 | + tblBrandMap = basicDataCacheService.getTblBrandRelationReverseMap(); |
57 | + ufoBrandMap = basicDataCacheService.getUfoRelationMapReverseMap(); | ||
58 | } | 58 | } |
59 | 59 | ||
60 | public void clearData() { | 60 | public void clearData() { |
service/src/main/java/com/yoho/search/consumer/service/logicService/cache/BasicDataCacheService.java
@@ -47,12 +47,14 @@ public class BasicDataCacheService { | @@ -47,12 +47,14 @@ public class BasicDataCacheService { | ||
47 | private static final String TBL_SITE_CACHE_KEY = "tblSite"; | 47 | private static final String TBL_SITE_CACHE_KEY = "tblSite"; |
48 | private static final String TBL_SORT_RELATION_CACHE_KEY = "tblSortRelation"; | 48 | private static final String TBL_SORT_RELATION_CACHE_KEY = "tblSortRelation"; |
49 | private static final String TBL_BRAND_RELATION_CACHE_KEY = "tblBrandRelation"; | 49 | private static final String TBL_BRAND_RELATION_CACHE_KEY = "tblBrandRelation"; |
50 | + private static final String TBL_BRAND_RELATION_REVERSE_CACHE_KEY = "tblBrandRelationReverse"; | ||
50 | //UFO | 51 | //UFO |
51 | private static final String UFO_BRAND_CACHE_KEY = "ufoBrand"; | 52 | private static final String UFO_BRAND_CACHE_KEY = "ufoBrand"; |
52 | private static final String UFO_BRAND_SERIES_CACHE_KEY = "ufoBrandSeries"; | 53 | private static final String UFO_BRAND_SERIES_CACHE_KEY = "ufoBrandSeries"; |
53 | private static final String UFO_SIZE_CACHE_KEY = "ufoSize"; | 54 | private static final String UFO_SIZE_CACHE_KEY = "ufoSize"; |
54 | private static final String UFO_BRAND_RELATION_CACHE_KEY = "ufoBrandRelation"; | 55 | private static final String UFO_BRAND_RELATION_CACHE_KEY = "ufoBrandRelation"; |
55 | private static final String UFO_SORT_RELATION_CACHE_KEY = "ufoSortRelation"; | 56 | private static final String UFO_SORT_RELATION_CACHE_KEY = "ufoSortRelation"; |
57 | + private static final String UFO_SORT_RELATION_REVERSE_CACHE_KEY = "ufoSortRelationReverse"; | ||
56 | 58 | ||
57 | //有货品牌 | 59 | //有货品牌 |
58 | LoadingCache<String, Map<Integer, Brand>> brandCache = CacheBuilder.newBuilder() | 60 | LoadingCache<String, Map<Integer, Brand>> brandCache = CacheBuilder.newBuilder() |
@@ -398,6 +400,28 @@ public class BasicDataCacheService { | @@ -398,6 +400,28 @@ public class BasicDataCacheService { | ||
398 | } | 400 | } |
399 | 401 | ||
400 | 402 | ||
403 | + //TBL品牌映射-反向 | ||
404 | + LoadingCache<String, Map<Integer, Integer>> tblBrandRelationReverseCache = CacheBuilder.newBuilder() | ||
405 | + .expireAfterWrite(10, TimeUnit.MINUTES) | ||
406 | + .build(new CacheLoader<String, Map<Integer, Integer>>() { | ||
407 | + public Map<Integer, Integer> load(String key) { | ||
408 | + return basicDataLogicService.getTblRelationMapReverse(); | ||
409 | + } | ||
410 | + }); | ||
411 | + | ||
412 | + public Map<Integer, Integer> getTblBrandRelationReverseMap() { | ||
413 | + try { | ||
414 | + return tblBrandRelationReverseCache.get(TBL_BRAND_RELATION_REVERSE_CACHE_KEY); | ||
415 | + } catch (Exception e) { | ||
416 | + logger.error(e.getMessage()); | ||
417 | + return new HashMap<>(); | ||
418 | + } | ||
419 | + } | ||
420 | + | ||
421 | + public void clearTblBrandRelationReverse() { | ||
422 | + tblBrandRelationReverseCache.invalidateAll(); | ||
423 | + } | ||
424 | + | ||
401 | //UFO品牌 | 425 | //UFO品牌 |
402 | LoadingCache<String, Map<Short, UfoBrand>> ufoBrandCache = CacheBuilder.newBuilder() | 426 | LoadingCache<String, Map<Short, UfoBrand>> ufoBrandCache = CacheBuilder.newBuilder() |
403 | .expireAfterWrite(10, TimeUnit.MINUTES) | 427 | .expireAfterWrite(10, TimeUnit.MINUTES) |
@@ -488,6 +512,28 @@ public class BasicDataCacheService { | @@ -488,6 +512,28 @@ public class BasicDataCacheService { | ||
488 | ufoBrandRelationCache.invalidateAll(); | 512 | ufoBrandRelationCache.invalidateAll(); |
489 | } | 513 | } |
490 | 514 | ||
515 | + //UFO品牌映射-反向 | ||
516 | + LoadingCache<String, Map<Integer, Integer>> ufoBrandRelationReverseCache = CacheBuilder.newBuilder() | ||
517 | + .expireAfterWrite(10, TimeUnit.MINUTES) | ||
518 | + .build(new CacheLoader<String, Map<Integer, Integer>>() { | ||
519 | + public Map<Integer, Integer> load(String key) { | ||
520 | + return basicDataLogicService.getUfoRelationMap(); | ||
521 | + } | ||
522 | + }); | ||
523 | + | ||
524 | + public Map<Integer, Integer> getUfoRelationMapReverseMap() { | ||
525 | + try { | ||
526 | + return ufoBrandRelationReverseCache.get(UFO_SORT_RELATION_REVERSE_CACHE_KEY); | ||
527 | + } catch (Exception e) { | ||
528 | + logger.error(e.getMessage()); | ||
529 | + return new HashMap<>(); | ||
530 | + } | ||
531 | + } | ||
532 | + | ||
533 | + public void clearUfoBrandRelationReverse() { | ||
534 | + ufoBrandRelationReverseCache.invalidateAll(); | ||
535 | + } | ||
536 | + | ||
491 | //UFO品类映射 | 537 | //UFO品类映射 |
492 | LoadingCache<String, Map<Integer, UfoSearchSortRelation>> ufoSortRelationCache = CacheBuilder.newBuilder() | 538 | LoadingCache<String, Map<Integer, UfoSearchSortRelation>> ufoSortRelationCache = CacheBuilder.newBuilder() |
493 | .expireAfterWrite(10, TimeUnit.MINUTES) | 539 | .expireAfterWrite(10, TimeUnit.MINUTES) |
service/src/main/java/com/yoho/search/consumer/service/logicService/cache/BasicDataLogicService.java
@@ -251,7 +251,21 @@ public class BasicDataLogicService { | @@ -251,7 +251,21 @@ public class BasicDataLogicService { | ||
251 | } | 251 | } |
252 | for (CsBrandRelation csBrandRelation : csBrandRelationList) { | 252 | for (CsBrandRelation csBrandRelation : csBrandRelationList) { |
253 | if (csBrandRelation.getTblBrandId() != null) { | 253 | if (csBrandRelation.getTblBrandId() != null) { |
254 | - tblRelationMap.put(csBrandRelation.getTblBrandId(),csBrandRelation.getYohoBrandId()); | 254 | + tblRelationMap.put(csBrandRelation.getTblBrandId(), csBrandRelation.getYohoBrandId()); |
255 | + } | ||
256 | + } | ||
257 | + return tblRelationMap; | ||
258 | + } | ||
259 | + | ||
260 | + public Map<Integer, Integer> getTblRelationMapReverse() { | ||
261 | + Map<Integer, Integer> tblRelationMap = new HashMap<>(); | ||
262 | + List<CsBrandRelation> csBrandRelationList = csBrandRelationService.selectAll(); | ||
263 | + if (CollectionUtils.isEmpty(csBrandRelationList)) { | ||
264 | + return new HashMap<>(); | ||
265 | + } | ||
266 | + for (CsBrandRelation csBrandRelation : csBrandRelationList) { | ||
267 | + if (csBrandRelation.getTblBrandId() != null) { | ||
268 | + tblRelationMap.put(csBrandRelation.getYohoBrandId(), csBrandRelation.getTblBrandId()); | ||
255 | } | 269 | } |
256 | } | 270 | } |
257 | return tblRelationMap; | 271 | return tblRelationMap; |
@@ -265,10 +279,25 @@ public class BasicDataLogicService { | @@ -265,10 +279,25 @@ public class BasicDataLogicService { | ||
265 | } | 279 | } |
266 | for (CsBrandRelation csBrandRelation : csBrandRelationList) { | 280 | for (CsBrandRelation csBrandRelation : csBrandRelationList) { |
267 | if (csBrandRelation.getUfoBrandId() != null) { | 281 | if (csBrandRelation.getUfoBrandId() != null) { |
268 | - ufoRelationMap.put(csBrandRelation.getUfoBrandId(),csBrandRelation.getYohoBrandId()); | 282 | + ufoRelationMap.put(csBrandRelation.getUfoBrandId(), csBrandRelation.getYohoBrandId()); |
269 | } | 283 | } |
270 | } | 284 | } |
271 | return ufoRelationMap; | 285 | return ufoRelationMap; |
272 | } | 286 | } |
273 | 287 | ||
288 | + public Map<Integer, Integer> getUfoRelationMapReverse() { | ||
289 | + Map<Integer, Integer> ufoRelationMap = new HashMap<>(); | ||
290 | + List<CsBrandRelation> csBrandRelationList = csBrandRelationService.selectAll(); | ||
291 | + if (CollectionUtils.isEmpty(csBrandRelationList)) { | ||
292 | + return new HashMap<>(); | ||
293 | + } | ||
294 | + for (CsBrandRelation csBrandRelation : csBrandRelationList) { | ||
295 | + if (csBrandRelation.getUfoBrandId() != null) { | ||
296 | + ufoRelationMap.put(csBrandRelation.getYohoBrandId(), csBrandRelation.getUfoBrandId()); | ||
297 | + } | ||
298 | + } | ||
299 | + return ufoRelationMap; | ||
300 | + } | ||
301 | + | ||
302 | + | ||
274 | } | 303 | } |
@@ -70,6 +70,8 @@ public class BrandRelationUtils { | @@ -70,6 +70,8 @@ public class BrandRelationUtils { | ||
70 | } | 70 | } |
71 | basicDataCacheService.clearTblBrandRelation(); | 71 | basicDataCacheService.clearTblBrandRelation(); |
72 | basicDataCacheService.clearUfoBrandRelation(); | 72 | basicDataCacheService.clearUfoBrandRelation(); |
73 | + basicDataCacheService.clearTblBrandRelationReverse(); | ||
74 | + basicDataCacheService.clearUfoBrandRelationReverse(); | ||
73 | return true; | 75 | return true; |
74 | } catch (Exception e) { | 76 | } catch (Exception e) { |
75 | logger.error(e.getMessage(), e); | 77 | logger.error(e.getMessage(), e); |
-
Please register or login to post a comment