Interface Weigher<K,V>
- Type Parameters:
K- the type of keysV- the type of values
- All Known Implementing Classes:
Async.AsyncWeigher, BoundedWeigher, SingletonWeigher
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Calculates the weights of cache entries. The total weight threshold is used to determine when an
eviction is required.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> @NonNull Weigher <K, V> boundedWeigher(@NonNull Weigher<K, V> delegate) Returns a weigher that enforces that the weight is non-negative.static <K,V> @NonNull Weigher <K, V> Returns a weigher where an entry has a weight of1.@NonNegative intReturns the weight of a cache entry.
-
Method Details
-
weigh
-
singletonWeigher
Returns a weigher where an entry has a weight of1.- Type Parameters:
K- the type of keysV- the type of values- Returns:
- a weigher where an entry has a weight of
1
-
boundedWeigher
Returns a weigher that enforces that the weight is non-negative.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
delegate- the weigher to weighs the entry- Returns:
- a weigher that enforces that the weight is non-negative
-