Constructor and Description |
---|
RecordCache() |
Modifier and Type | Method and Description |
---|---|
abstract long |
estimateCurrentWeight() |
static <T> @NotNull Supplier<RecordCache<T>> |
factory(int size) |
static <T> @NotNull Supplier<RecordCache<T>> |
factory(int size,
@NotNull Weigher<T,RecordId> weigher) |
@NotNull CacheStats |
getStats() |
static <T> @NotNull RecordCache<T> |
newRecordCache(int size)
Factory method for creating
RecordCache instances. |
void |
put(K key,
@NotNull RecordId value,
byte cost)
Add a mapping from
key to value with a given cost . |
abstract long |
size() |
public abstract long size()
public abstract long estimateCurrentWeight()
public void put(@NotNull K key, @NotNull @NotNull RecordId value, byte cost)
Cache
key
to value
with a given cost
.@NotNull public @NotNull CacheStats getStats()
@NotNull public static <T> @NotNull RecordCache<T> newRecordCache(int size)
RecordCache
instances. The returned
instances are all thread safe. They implement a simple LRU behaviour where
the least recently accessed mapping would be replaced when inserting a
new mapping would exceed size
.RecordCache
instance of the given size
.@NotNull public static <T> @NotNull Supplier<RecordCache<T>> factory(int size, @NotNull @NotNull Weigher<T,RecordId> weigher)
size
- size of the cacheweigher
- Needed to provide an estimation of the cache weight in memoryRecordCache
instances of the given size
when invoked.newRecordCache(int)
@NotNull public static <T> @NotNull Supplier<RecordCache<T>> factory(int size)
size
- size of the cacheRecordCache
instances of the given size
when invoked.newRecordCache(int)
Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.