You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/28 13:03:46 UTC

[GitHub] [rocketmq] zhouxinyu commented on a diff in pull request #4669: using caffeine replace guava cache

zhouxinyu commented on code in PR #4669:
URL: https://github.com/apache/rocketmq/pull/4669#discussion_r932191535


##########
proxy/src/main/java/org/apache/rocketmq/proxy/service/route/TopicRouteService.java:
##########
@@ -64,10 +68,14 @@ public TopicRouteService(MQClientAPIFactory mqClientAPIFactory) {
             config.getTopicRouteServiceThreadPoolQueueCapacity()
         );
         this.mqClientAPIFactory = mqClientAPIFactory;
-        this.topicCache = CacheBuilder.newBuilder()
-            .maximumSize(config.getTopicRouteServiceCacheMaxNum())
-            .refreshAfterWrite(config.getTopicRouteServiceCacheExpiredInSeconds(), TimeUnit.SECONDS)
-            .build(new TopicRouteCacheLoader());
+
+        this.topicCache = Caffeine.newBuilder().maximumSize(config.getTopicRouteServiceCacheMaxNum()).
+            refreshAfterWrite(config.getTopicRouteServiceCacheExpiredInSeconds(), TimeUnit.SECONDS).
+            executor(cacheRefreshExecutor).build(new CacheLoader<String, MessageQueueView>() {
+                @Override public @Nullable MessageQueueView load(String topic) throws Exception {
+                    return topicRouteCacheLoader.load(topic);

Review Comment:
   Does caffeine have the same error handling process as guava cache?
   
   We must ensure that:
   1. TopicRoute info should be discarded if TOPIC_NOT_EXIST occurs.
   2. TopicRoute info should be kept if unexpected exceptions occur to tolerate namesrv failure.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org