@Test public void evictionDuringLoad() throws ExecutionException { cache.getSegment(id3, () -> segment3); expect(SegmentNotFoundException.class, id3::getSegment); AtomicBoolean cached = new AtomicBoolean(true); assertEquals(segment3, cache.getSegment(id3, () -> { cached.set(false); return segment3; })); assertFalse(cached.get()); }
@NotNull public abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader) throws ExecutionException;
SegmentCache { @NotNull public abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader) throws ExecutionException; }
SegmentCache { @NotNull public abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader) throws ExecutionException;  }
SegmentCache { @NotNull public abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader) throws ExecutionException;  @NotNull static SegmentCache newSegmentCache(long cacheSizeMB); @NotNull abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader); abstract void putSegment(@NotNull Segment segment); abstract void clear(); @NotNull abstract AbstractCacheStats getCacheStats(); abstract void recordHit(); }
SegmentCache { @NotNull public abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader) throws ExecutionException;  @NotNull static SegmentCache newSegmentCache(long cacheSizeMB); @NotNull abstract Segment getSegment(@NotNull SegmentId id, @NotNull Callable<Segment> loader); abstract void putSegment(@NotNull Segment segment); abstract void clear(); @NotNull abstract AbstractCacheStats getCacheStats(); abstract void recordHit(); static final int DEFAULT_SEGMENT_CACHE_MB; }