瀏覽代碼

召回内容历史表现增加缓存

wangyunpeng 7 月之前
父節點
當前提交
ede2e51c43

+ 7 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -519,4 +519,11 @@ public class XxlJobService {
                 "次条利用池_v4", 100, 1.33, Lists.newArrayList(3, 4, 5, 6, 7, 8));
         return ReturnT.SUCCESS;
     }
+
+    @XxlJob("refreshArticleHisCache")
+    public ReturnT<String> refreshArticleHisCache(String param) {
+        // todo 刷新历史表现缓存
+        return ReturnT.SUCCESS;
+    }
+
 }

+ 5 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java

@@ -268,12 +268,14 @@ public class RecallService implements ApplicationContextAware {
 
     public void setTitleAvgViewCount(List<Content> contentList, String ghId, String type) {
         long start = System.currentTimeMillis();
+
+        Set<String> titleMd5List = contentList.stream().map(o -> Md5Util.encoderByMd5(o.getTitle())).collect(Collectors.toSet());
+        // todo 根据titleMd5查询数据库获取数据
+        // todo titleMd5 进行过滤 排除缓存中数据 重新走下方查询
         // 获取账号相关性
         List<AccountCorrelation> accountCorrelationList = accountCorrelationRepository.findByGhIdAndStatus(ghId, 1);
         Map<String, Double> accountCorrelationMap = accountCorrelationList.stream().collect(
                 Collectors.toMap(AccountCorrelation::getRelGhId, AccountCorrelation::getCorrelation));
-
-        Set<String> titleMd5List = contentList.stream().map(o -> Md5Util.encoderByMd5(o.getTitle())).collect(Collectors.toSet());
 //        Set<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toSet());
 //        Set<String> crawlerTitleList = contentList.stream().map(Content::getCrawlerTitle).collect(Collectors.toSet());
 //        titleList.addAll(crawlerTitleList);
@@ -410,6 +412,7 @@ public class RecallService implements ApplicationContextAware {
             }
             // 设置头条阅读均值
             setT0Data(content);
+            // todo 写入缓存
         }
         log.info("setTitleAvgViewCount cost:{}", System.currentTimeMillis() - start);
     }

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/XxlJobController.java

@@ -69,4 +69,9 @@ public class XxlJobController {
         service.articleCategoryJobRetry(null);
     }
 
+    @GetMapping("/refreshArticleHisCache")
+    public void refreshArticleHisCache() {
+        service.refreshArticleHisCache(null);
+    }
+
 }