Top Description Interfaces Classes Enums
module com.github.benmanes.caffeine

Package com.github.benmanes.caffeine.cache

Annotations
@CheckReturnValue
@List:@org.checkerframework.framework.qual.DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class, locations={FIELD}), @org.checkerframework.framework.qual.DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class, locations={PARAMETER}), @org.checkerframework.framework.qual.DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class, locations={RETURN})
Imports
org.checkerframework.checker.nullness.qual.NonNull, org.checkerframework.framework.qual.DefaultQualifier, .TypeUseLocation, com.google.errorprone.annotations.CheckReturnValue

This package contains in-memory caching functionality. All cache variants are configured and created using the com.github.benmanes.caffeine.cache.Caffeine builder.

A com.github.benmanes.caffeine.cache.Cache provides similar characteristics to java.util.concurrent.ConcurrentHashMap, with additional support for policies to bound the map. When built with a com.github.benmanes.caffeine.cache.CacheLoader, the com.github.benmanes.caffeine.cache.LoadingCache variant allows the cache to populate itself on a miss and offers refresh capabilities.

A com.github.benmanes.caffeine.cache.AsyncCache is similar to a com.github.benmanes.caffeine.cache.Cache, except that a cache entry holds a java.util.concurrent.CompletableFuture of the value. This entry will be automatically removed if the future fails, resolves to null, or based on an eviction policy. When built with a com.github.benmanes.caffeine.cache.AsyncCacheLoader, the com.github.benmanes.caffeine.cache.AsyncLoadingCache variant allows the cache to populate itself on a miss and offers refresh capabilities.

Additional functionality such as bounding by the entry's size, removal notifications, statistics, and eviction policies are described in the com.github.benmanes.caffeine.cache.Caffeine builder.

Author
[email protected] (Ben Manes)

Interface Summary

Modifier and TypeInterface and Description
public interface
AsyncCache<
the type of keys maintained by this cache
K
,
the type of mapped values
V
>

A semi-persistent mapping from keys to values.

public interface
AsyncCacheLoader<K, V>

Computes or retrieves values asynchronously based on a key, for use in populating a AsyncLoadingCache.

public interface
AsyncLoadingCache<
the type of keys maintained by this cache
K
,
the type of mapped values
V
>

A semi-persistent mapping from keys to values.

pack-priv interface
Buffer<
the type of elements maintained by this buffer
E
>

A multiple-producer / single-consumer buffer that rejects new elements if it is full or fails spuriously due to contention.

public interface
Cache<
the type of keys maintained by this cache
K
,
the type of mapped values
V
>

A semi-persistent mapping from keys to values.

public interface
CacheLoader<K, V>

Computes or retrieves values, based on a key, for use in populating a LoadingCache or AsyncLoadingCache.

public interface
Expiry<K, V>

Calculates when cache entries expire.

public interface
Interner<
the type of elements
E
>

Provides similar behavior to String#intern for any immutable type.

pack-priv interface
LinkedDeque<
the type of elements held in this collection
E
>

A linked list extension of the Deque interface where the link pointers are tightly integrated with the element.

public interface
LoadingCache<
the type of keys maintained by this cache
K
,
the type of mapped values
V
>

A semi-persistent mapping from keys to values.

pack-priv interface
LocalAsyncCache<K, V>

This class provides a skeletal implementation of the AsyncCache interface to minimize the effort required to implement a LocalCache.

pack-priv interface
LocalCache<K, V>

An in-memory cache providing thread safety and atomicity guarantees.

pack-priv interface
LocalCacheFactory

A factory for caches optimized for a particular configuration.

pack-priv interface
LocalLoadingCache<K, V>

This class provides a skeletal implementation of the LoadingCache interface to minimize the effort required to implement a LocalCache.

pack-priv interface
LocalManualCache<K, V>

This class provides a skeletal implementation of the Cache interface to minimize the effort required to implement a LocalCache.

pack-priv interface
NodeFactory<K, V>

A factory for cache nodes optimized for a particular configuration.

public interface
Policy<K, V>

An access point for inspecting and performing low-level operations based on the cache's runtime characteristics.

public interface
RemovalListener<
the most general type of keys this listener can listen for; for example Object if any key is acceptable
K
,
the most general type of values this listener can listen for; for example Object if any value is acceptable
V
>

An object that can receive a notification when an entry is removed from a cache.

public interface
Scheduler

A scheduler that submits a task to an executor after a given delay.

public interface
Ticker

A time source that returns a time value representing the number of nanoseconds elapsed since some fixed but arbitrary point in time.

public interface
Weigher<
the type of keys
K
,
the type of values
V
>

Calculates the weights of cache entries.

Class Summary

Modifier and TypeClass and Description
pack-priv abstract class
AbstractLinkedDeque<
the type of elements held in this collection
E
>

This class provides a skeletal implementation of the LinkedDeque interface to minimize the effort required to implement this interface.

pack-priv class
AccessOrderDeque<
the type of elements held in this collection
E extends AccessOrderDeque.AccessOrder<E>
>

A linked deque implementation used to represent an access-order queue.

pack-priv class
Async

Static utility methods and classes pertaining to asynchronous operations.

pack-priv abstract class
pack-priv abstract class
pack-priv abstract class
pack-priv abstract class
pack-priv abstract class
pack-priv abstract class
pack-priv abstract class
pack-priv class
BBHeader

The namespace for field padding through inheritance.

pack-priv class
BLCHeader

The namespace for field padding through inheritance.

pack-priv class
BoundedBuffer<
the type of elements maintained by this buffer
E
>

A striped, non-blocking, bounded buffer.

pack-priv abstract class
BoundedLocalCache<
the type of keys maintained by this cache
K
,
the type of mapped values
V
>

An in-memory cache implementation that supports full concurrency of retrievals, a high expected concurrency for updates, and multiple ways to bound the cache.

pack-priv class
public class
Caffeine<
the most general key type this builder will be able to create caches for. This is normally Object unless it is constrained by using a method like #removalListener
K
,
the most general value type this builder will be able to create caches for. This is normally Object unless it is constrained by using a method like #removalListener
V
>

A builder of Cache, LoadingCache, AsyncCache, and AsyncLoadingCache instances having a combination of the following features:

  • automatic loading of entries into the cache, optionally asynchronously
  • size-based eviction when a maximum is exceeded based on frequency and recency
  • time-based expiration of entries, measured since last access or last write
  • asynchronously refresh when the first stale request for an entry occurs
  • keys automatically wrapped in weak references
  • values automatically wrapped in weak or soft references
  • writes propagated to an external resource
  • notification of evicted (or otherwise removed) entries
  • accumulation of cache access statistics
public class
CaffeineSpec

A specification of a Caffeine builder configuration.

pack-priv class
pack-priv class
FrequencySketch<E>

A probabilistic multiset for estimating the popularity of an element within a time window.

pack-priv class
pack-priv class
Interned<K, V>

pack-priv abstract class
LocalAsyncLoadingCache<K, V>

This class provides a skeletal implementation of the AsyncLoadingCache interface to minimize the effort required to implement a LocalCache.

pack-priv abstract class
pack-priv abstract class
pack-priv class
MpscGrowableArrayQueue<E>

An MPSC array queue which starts at initialCapacity and grows to maxCapacity in linked chunks of the initial size.

pack-priv abstract class
Node<K, V>

An entry in the cache containing the key, value, weight, access, and write metadata.

pack-priv class
Pacer

A pacing scheduler that prevents executions from happening too frequently.

pack-priv class
References

Static utility methods and classes pertaining to weak and soft references.

pack-priv class
SerializationProxy<K, V>

Serializes the configuration of the cache, reconstituting it as a Cache, LoadingCache, AsyncCache, or AsyncLoadingCache using Caffeine upon deserialization.

pack-priv class
SnapshotEntry<K, V>

An immutable entry that includes a snapshot of the policy metadata at its time of creation.

pack-priv abstract class
StripedBuffer<E>

A base class providing the mechanics for supporting dynamic striping of bounded buffers.

pack-priv class
pack-priv class
TimerWheel<K, V>

A hierarchical timer wheel to add, remove, and fire expiration events in amortized O(1) time.

pack-priv class
UnboundedLocalCache<K, V>

An in-memory cache that has no capabilities for bounding the map.

pack-priv class
pack-priv class
WriteOrderDeque<
the type of elements held in this collection
E extends WriteOrderDeque.WriteOrder<E>
>

A linked deque implementation used to represent a write-order queue.

pack-priv class
WriteThroughEntry<K, V>

An entry that allows updates to write through to the backing map.

Enum Summary

Modifier and TypeEnum and Description
pack-priv enum
pack-priv enum
pack-priv enum
pack-priv enum
public enum
RemovalCause

The reason why a cached entry was removed.

pack-priv enum
pack-priv enum
pack-priv enum