dlmarion commented on code in PR #2709:
URL: https://github.com/apache/accumulo/pull/2709#discussion_r874109558


##########
core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCacheFactory.java:
##########
@@ -18,18 +18,17 @@
  */
 package org.apache.accumulo.fate.zookeeper;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.accumulo.core.singletons.SingletonManager;
 import org.apache.accumulo.core.singletons.SingletonService;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 /**
  * A factory for {@link ZooCache} instances.
  */
 public class ZooCacheFactory {
-  // TODO: make this better - LRU, soft references, ...
-  private static Map<String,ZooCache> instances = new HashMap<>();
+  private static Cache<String,ZooCache> instances = 
Caffeine.newBuilder().maximumSize(5).build();

Review Comment:
   For Caffeine, specifying a size turns the Cache into an LRU Cache (see 
https://github.com/ben-manes/caffeine/wiki/Eviction#size-based). As for the 
number 5, it was arbitrary. I don't know how many ZK's a ClientContext actually 
communicates with, it's probably 1. But a Cache of 1 didn't make sense. What's 
your thought?



-- 
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