Modifier and Type | Method and Description |
---|---|
Map<K,V> |
coldest(int limit)
Returns an unmodifiable snapshot
Map view of the cache with ordered traversal. |
long |
getMaximum()
Returns the maximum total weighted or unweighted size of this cache, depending on how the
cache was constructed.
|
Map<K,V> |
hottest(int limit)
Returns an unmodifiable snapshot
Map view of the cache with ordered traversal. |
boolean |
isWeighted()
Returns whether the cache is bounded by a maximum size or maximum weight.
|
void |
setMaximum(long maximum)
Specifies the maximum total size of this cache.
|
OptionalLong |
weightedSize()
Returns the approximate accumulated weight of entries in this cache.
|
default OptionalInt |
weightOf(K key)
Returns the weight of the entry.
|
boolean isWeighted()
@Nonnull default OptionalInt weightOf(@Nonnull K key)
OptionalInt
will be empty.key
- the key for the entry being queried@Nonnull OptionalLong weightedSize()
OptionalLong
will be empty.@Nonnegative long getMaximum()
isWeighted()
.void setMaximum(@Nonnegative long maximum)
Note that some implementations may have an internal inherent bound on the maximum total size. If the value specified exceeds that bound, then the value is set to the internal maximum.
maximum
- the maximum, interpreted as weighted or unweighted size depending on how this
cache was constructedIllegalArgumentException
- if the maximum size specified is negative@Nonnull Map<K,V> coldest(@Nonnegative int limit)
Map
view of the cache with ordered traversal. The
order of iteration is from the entries least likely to be retained (coldest) to the entries
most likely to be retained (hottest). This order is determined by the eviction policy's best
guess at the time of creating this snapshot view.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit
- the maximum size of the returned map (use Integer.MAX_VALUE
to disregard
the limit)@Nonnull Map<K,V> hottest(@Nonnegative int limit)
Map
view of the cache with ordered traversal. The
order of iteration is from the entries most likely to be retained (hottest) to the entries
least likely to be retained (coldest). This order is determined by the eviction policy's best
guess at the time of creating this snapshot view.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit
- the maximum size of the returned map (use Integer.MAX_VALUE
to disregard
the limit)