@ParametersAreNonnullByDefault
Package com.google.common.cache
This package contains caching utilities.
The core interface used to represent caches is Cache
.
In-memory caches can be configured and created using CacheBuilder
, with cache entries being loaded by CacheLoader
. Statistics about cache performance are exposed using CacheStats
.
See the Guava User Guide article on caches.
This package is a part of the open-source Guava library.
-
Interface Summary Interface Description AbstractCache.StatsCounter Accumulates statistics during the operation of aCache
for presentation byCache.stats()
.Cache<K,V> A semi-persistent mapping from keys to values.CacheBuilderSpec.ValueParser Parses a single value.LoadingCache<K,V> A semi-persistent mapping from keys to values.LocalCache.ReferenceEntry<K,V> An entry in a reference map.LocalCache.ValueReference<K,V> A reference to a value.LongAddable Abstract interface for objects that can concurrently add longs.RemovalListener<K,V> An object that can receive a notification when an entry is removed from a cache.Weigher<K,V> Calculates the weights of cache entries. -
Class Summary Class Description AbstractCache<K,V> This class provides a skeletal implementation of theCache
interface to minimize the effort required to implement this interface.AbstractCache.SimpleStatsCounter A thread-safeAbstractCache.StatsCounter
implementation for use byCache
implementors.AbstractLoadingCache<K,V> This class provides a skeletal implementation of theCache
interface to minimize the effort required to implement this interface.CacheBuilder<K,V> A builder ofLoadingCache
andCache
instances having any combination of the following features: automatic loading of entries into the cache least-recently-used eviction when a maximum size is exceeded time-based expiration of entries, measured since last access or last write keys automatically wrapped in weak references values automatically wrapped in weak or soft references notification of evicted (or otherwise removed) entries accumulation of cache access statisticsCacheBuilderSpec A specification of aCacheBuilder
configuration.CacheBuilderSpec.AccessDurationParser Parse expireAfterAccessCacheBuilderSpec.ConcurrencyLevelParser Parse concurrencyLevelCacheBuilderSpec.DurationParser Base class for parsing times with durationsCacheBuilderSpec.InitialCapacityParser Parse initialCapacityCacheBuilderSpec.IntegerParser Base class for parsing integers.CacheBuilderSpec.KeyStrengthParser Parse weakKeysCacheBuilderSpec.LongParser Base class for parsing integers.CacheBuilderSpec.MaximumSizeParser Parse maximumSizeCacheBuilderSpec.MaximumWeightParser Parse maximumWeightCacheBuilderSpec.RecordStatsParser Parse recordStatsCacheBuilderSpec.RefreshDurationParser Parse refreshAfterWriteCacheBuilderSpec.ValueStrengthParser Parse weakValues and softValuesCacheBuilderSpec.WriteDurationParser Parse expireAfterWriteCacheLoader<K,V> Computes or retrieves values, based on a key, for use in populating aLoadingCache
.CacheLoader.FunctionToCacheLoader<K,V> CacheLoader.SupplierToCacheLoader<V> CacheStats Statistics about the performance of aCache
.ForwardingCache<K,V> A cache which forwards all its method calls to another cache.ForwardingCache.SimpleForwardingCache<K,V> A simplified version ofForwardingCache
where subclasses can pass in an already constructedCache
as the delegate.ForwardingLoadingCache<K,V> A cache which forwards all its method calls to another cache.ForwardingLoadingCache.SimpleForwardingLoadingCache<K,V> A simplified version ofForwardingLoadingCache
where subclasses can pass in an already constructedLoadingCache
as the delegate.LocalCache<K,V> The concurrent hash map implementation built byCacheBuilder
.LocalCache.AbstractReferenceEntry<K,V> LocalCache.AccessQueue<K,V> A custom queue for managing access order.LocalCache.LoadingSerializationProxy<K,V> Serializes the configuration of a LocalCache, reconsitituting it as an LoadingCache using CacheBuilder upon deserialization.LocalCache.LoadingValueReference<K,V> LocalCache.LocalLoadingCache<K,V> LocalCache.LocalManualCache<K,V> LocalCache.ManualSerializationProxy<K,V> Serializes the configuration of a LocalCache, reconsitituting it as a Cache using CacheBuilder upon deserialization.LocalCache.Segment<K,V> Segments are specialized versions of hash tables.LocalCache.SoftValueReference<K,V> References a soft value.LocalCache.StrongAccessEntry<K,V> LocalCache.StrongAccessWriteEntry<K,V> LocalCache.StrongEntry<K,V> Used for strongly-referenced keys.LocalCache.StrongValueReference<K,V> References a strong value.LocalCache.StrongWriteEntry<K,V> LocalCache.WeakAccessEntry<K,V> LocalCache.WeakAccessWriteEntry<K,V> LocalCache.WeakEntry<K,V> Used for weakly-referenced keys.LocalCache.WeakValueReference<K,V> References a weak value.LocalCache.WeakWriteEntry<K,V> LocalCache.WeightedSoftValueReference<K,V> References a soft value.LocalCache.WeightedStrongValueReference<K,V> References a strong value.LocalCache.WeightedWeakValueReference<K,V> References a weak value.LocalCache.WriteQueue<K,V> A custom queue for managing eviction order.LongAddables Source ofLongAddable
objects that deals with GWT, Unsafe, and all that.LongAddables.PureJavaLongAddable LongAdder One or more variables that together maintain an initially zerolong
sum.RemovalListeners A collection of common removal listeners.RemovalNotification<K,V> A notification of the removal of a single entry.Striped64 A package-local class holding common representation and mechanics for classes supporting dynamic striping on 64bit values.Striped64.Cell Padded variant of AtomicLong supporting only raw accesses plus CAS. -
Enum Summary Enum Description CacheBuilder.NullListener CacheBuilder.OneWeigher LocalCache.EntryFactory Creates new entries.LocalCache.NullEntry LocalCache.Strength RemovalCause The reason why a cached entry was removed. -
Exception Summary Exception Description CacheLoader.InvalidCacheLoadException Thrown to indicate that an invalid response was returned from a call toCacheLoader
.CacheLoader.UnsupportedLoadingOperationException Exception thrown byloadAll()
to indicate that it is not supported.