public class SegmentCache extends Object
Segmentinstances by their
Conceptually this cache serves as a 2nd level cache for segments. The 1st level cache is
implemented by memoising the segment in its id (see
SegmentId.segment. Every time
an segment is evicted from this cache the memoised segment is discarded (see
As a consequence this cache is actually only queried for segments it does not contain,
which are then loaded through the loader passed to
This behaviour is eventually reflected in the cache statistics (see
which always reports a
AbstractCacheStats.getHitRate() () miss rate} of 1.
|Modifier and Type||Field and Description|
|Constructor and Description|
Create a new segment cache of the given size.
|Modifier and Type||Method and Description|
Clear all segment from the cache
See the class comment regarding some peculiarities of this cache's statistics
Retrieve an segment from the cache or load it and cache it if not yet in the cache.
Put a segment into the cache
public static final int DEFAULT_SEGMENT_CACHE_MB
public SegmentCache(long cacheSizeMB)
cacheSizeMB- size of the cache in megabytes.
@Nonnull public Segment getSegment(@Nonnull SegmentId id, @Nonnull Callable<Segment> loader) throws ExecutionException
id- the id of the segment
loader- the loader to load the segment if not yet in the cache
loaderfailed to load an segment
segment- the segment to cache
public void clear()
Copyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.