K - the type of keysV - the type of values@ThreadSafe @FunctionalInterface public interface Weigher<K,V>
| Modifier and Type | Method and Description |
|---|---|
static <K,V> Weigher<K,V> |
boundedWeigher(Weigher<K,V> delegate)
Returns a weigher that enforces that the weight is non-negative.
|
static <K,V> Weigher<K,V> |
singletonWeigher()
Returns a weigher where an entry has a weight of
1. |
int |
weigh(K key,
V value)
Returns the weight of a cache entry.
|
@Nonnegative int weigh(@Nonnull K key, @Nonnull V value)
key - the key to weighvalue - the value to weigh@Nonnull static <K,V> Weigher<K,V> singletonWeigher()
1.K - the type of keysV - the type of values1@Nonnull static <K,V> Weigher<K,V> boundedWeigher(@Nonnull Weigher<K,V> delegate)
K - the type of keysV - the type of valuesdelegate - the weigher to weighs the entry