This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git

commit da5d508caffc4ca90b0ab962b5105785b9774daa
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Mon Aug 26 11:07:17 2024 -0700

    Revert "RATIS-2101. Move TermIndex.PRIVATE_CACHE to Util.CACHE (#1103)"
    
    This reverts commit 93eb32a8620fdd4e5119592ef32bc50590810c7b.
---
 .../java/org/apache/ratis/server/protocol/TermIndex.java  | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git 
a/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java
 
b/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java
index a8aa67061..6a9bd1cfb 100644
--- 
a/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java
+++ 
b/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java
@@ -29,14 +29,11 @@ import java.util.concurrent.TimeUnit;
 
 /** The term and the log index defined in the Raft consensus algorithm. */
 public interface TermIndex extends Comparable<TermIndex> {
-  class Util {
-    /** An LRU Cache for {@link TermIndex} instances */
-    private static final Cache<TermIndex, TermIndex> CACHE = 
CacheBuilder.newBuilder()
-          .maximumSize(1 << 16)
-          .expireAfterAccess(1, TimeUnit.MINUTES)
-          .build();
-  }
-  TermIndex[] EMPTY_ARRAY = {};
+  /** An LRU Cache for {@link TermIndex} instances */
+  Cache<TermIndex, TermIndex> PRIVATE_CACHE = CacheBuilder.newBuilder()
+      .maximumSize(1 << 16)
+      .expireAfterAccess(1, TimeUnit.MINUTES)
+      .build();
 
   /** @return the term. */
   long getTerm();
@@ -110,7 +107,7 @@ public interface TermIndex extends Comparable<TermIndex> {
       }
     };
     try {
-      return Util.CACHE.get(key, () -> key);
+      return PRIVATE_CACHE.get(key, () -> key);
     } catch (ExecutionException e) {
       throw new IllegalStateException("Failed to valueOf(" + term + ", " + 
index + "), key=" + key, e);
     }

Reply via email to