Skip to content

Commit

Permalink
Revert "RATIS-2101. Move TermIndex.PRIVATE_CACHE to Util.CACHE (apach…
Browse files Browse the repository at this point in the history
…e#1103)"

This reverts commit 93eb32a.
  • Loading branch information
szetszwo committed Aug 26, 2024
1 parent c266cad commit da5d508
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@

/** 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();
Expand Down Expand Up @@ -110,7 +107,7 @@ public String toString() {
}
};
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);
}
Expand Down

0 comments on commit da5d508

Please sign in to comment.