drpmma commented on code in PR #6554:
URL: https://github.com/apache/rocketmq/pull/6554#discussion_r1172148582


##########
proxy/src/main/java/org/apache/rocketmq/proxy/common/AbstractCacheLoader.java:
##########
@@ -16,31 +16,25 @@
  */
 package org.apache.rocketmq.proxy.common;
 
-import com.google.common.cache.CacheLoader;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListenableFutureTask;
-import java.util.concurrent.ThreadPoolExecutor;
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
 import javax.annotation.Nonnull;
 
-public abstract class AbstractCacheLoader<K, V> extends CacheLoader<K, V> {
-    private final ThreadPoolExecutor cacheRefreshExecutor;
+public abstract class AbstractCacheLoader<K, V> implements CacheLoader<K, V> {
 
-    public AbstractCacheLoader(ThreadPoolExecutor cacheRefreshExecutor) {
-        this.cacheRefreshExecutor = cacheRefreshExecutor;
-    }
-
-    @Override
-    public ListenableFuture<V> reload(@Nonnull K key, @Nonnull V oldValue) 
throws Exception {
-        ListenableFutureTask<V> task = ListenableFutureTask.create(() -> {
+    @Override @Nonnull
+    public CompletableFuture<V> asyncReload(@Nonnull K key, @Nonnull V 
oldValue, @Nonnull Executor executor) {
+        CompletableFuture<V> future = new CompletableFuture<>();
+        executor.execute(() -> {
             try {
-                return getDirectly(key);
+                future.complete(getDirectly(key));

Review Comment:
   Now that the cacheloader uses an async interface. Why not implement 
AsyncCacheLoader directly?
   And would it be better that `getDirectly` also returns a future to adapt to 
the potential async interface?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to