Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@

/** The term and the log index defined in the Raft consensus algorithm. */
public interface TermIndex extends Comparable<TermIndex> {
/** An LRU Cache for {@link TermIndex} instances */
Cache<TermIndex, TermIndex> PRIVATE_CACHE = CacheBuilder.newBuilder()
.maximumSize(1 << 16)
.expireAfterAccess(1, TimeUnit.MINUTES)
.build();
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 = {};

/** @return the term. */
long getTerm();
Expand Down Expand Up @@ -107,7 +110,7 @@ public String toString() {
}
};
try {
return PRIVATE_CACHE.get(key, () -> key);
return Util.CACHE.get(key, () -> key);
} catch (ExecutionException e) {
throw new IllegalStateException("Failed to valueOf(" + term + ", " + index + "), key=" + key, e);
}
Expand Down