public abstract class SegmentCache extends Object
data
Segment
instances by their SegmentId
. This cache ignores bulk
segments.
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 SegmentId#onAccess
.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SEGMENT_CACHE_MB
Default maximum weight of this cache in MB
|
Constructor and Description |
---|
SegmentCache() |
Modifier and Type | Method and Description |
---|---|
abstract void |
clear()
Clear all segment from the cache
|
abstract @NotNull org.apache.jackrabbit.oak.cache.AbstractCacheStats |
getCacheStats() |
abstract @NotNull Segment |
getSegment(@NotNull SegmentId id,
@NotNull Callable<Segment> loader)
Retrieve an segment from the cache or load it and cache it if not yet in
the cache.
|
static @NotNull SegmentCache |
newSegmentCache(long cacheSizeMB)
Create a new segment cache of the given size.
|
abstract void |
putSegment(@NotNull Segment segment)
Put a segment into the cache.
|
abstract void |
recordHit()
Record a hit in this cache's underlying statistics.
|
public static final int DEFAULT_SEGMENT_CACHE_MB
@NotNull public static @NotNull SegmentCache newSegmentCache(long cacheSizeMB)
cacheSizeMB <= 0
.cacheSizeMB
- size of the cache in megabytes.@NotNull public abstract @NotNull Segment getSegment(@NotNull @NotNull SegmentId id, @NotNull @NotNull Callable<Segment> loader) throws ExecutionException
id
- the id of the segmentloader
- the loader to load the segment if not yet in the cacheid
ExecutionException
- when loader
failed to load an segmentpublic abstract void putSegment(@NotNull @NotNull Segment segment)
bulk
segments.segment
- the segment to cachepublic abstract void clear()
@NotNull public abstract @NotNull org.apache.jackrabbit.oak.cache.AbstractCacheStats getCacheStats()
public abstract void recordHit()
SegmentId#onAccess
Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.