Top Description Inners Methods
com.github.benmanes.caffeine.cache

public Interface Policy<K, V>

Known Direct Implementers
com.github.benmanes.caffeine.cache.UnboundedLocalCache.UnboundedPolicy, com.github.benmanes.caffeine.cache.BoundedLocalCache.BoundedPolicy
Static Imports
com.github.benmanes.caffeine.cache.Caffeine.saturatedToNanos

An access point for inspecting and performing low-level operations based on the cache's runtime characteristics. These operations are optional and dependent on how the cache was constructed and what abilities the implementation exposes.
Author
[email protected] (Ben Manes)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Policy.CacheEntry<K, V>

A key-value pair that may include policy metadata for the cached entry.

public static interface
Policy.Eviction<K, V>

The low-level operations for a cache with a size-based eviction policy.

public static interface
Policy.FixedExpiration<K, V>

The low-level operations for a cache with a fixed expiration policy.

public static interface
Policy.FixedRefresh<K, V>

The low-level operations for a cache with a fixed refresh policy.

public static interface
Policy.VarExpiration<K, V>

The low-level operations for a cache with a variable expiration policy.

Method Summary

Modifier and TypeMethod and Description
public Optional<Policy.Eviction<K, V>>

Returns:

access to low-level operations for this cache if an eviction policy is used
eviction
()

Returns access to perform operations based on the maximum size or maximum weight eviction policy.

public Optional<Policy.FixedExpiration<K, V>>

Returns:

access to low-level operations for this cache if a time-to-idle expiration policy is used
expireAfterAccess
()

Returns access to perform operations based on the time-to-idle expiration policy.

public Optional<Policy.FixedExpiration<K, V>>

Returns:

access to low-level operations for this cache if a time-to-live expiration policy is used
expireAfterWrite
()

Returns access to perform operations based on the time-to-live expiration policy.

public Optional<Policy.VarExpiration<K, V>>

Returns:

access to low-level operations for this cache if a variable expiration policy is used
expireVariably
()

Returns access to perform operations based on the variable expiration policy.

public default @Nullable Policy.CacheEntry<K, V>

Returns:

the entry mapping for the specified key, or null if this cache contains no mapping for the key
getEntryIfPresentQuietly
(K
the key whose associated value is to be returned
key
)

Returns the cache entry associated with the key in this cache, or null if there is no cached value for the key.

public @Nullable V

Returns:

the value to which the specified key is mapped, or null if this cache contains no mapping for the key
getIfPresentQuietly
(K
the key whose associated value is to be returned
key
)

Returns the value associated with the key in this cache, or null if there is no cached value for the key.

public boolean

Returns:

if cache statistics are being recorded
isRecordingStats
()

Returns whether the cache statistics are being accumulated.

public Optional<Policy.FixedRefresh<K, V>>

Returns:

access to low-level operations for this cache if a time-to-live refresh policy is used
refreshAfterWrite
()

Returns access to perform operations based on the time-to-live refresh policy.

public Map<K, CompletableFuture<V>>

Returns:

a snapshot view of the in-flight refresh operations
refreshes
()

Returns an unmodifiable snapshot Map view of the in-flight refresh operations.