Builds a cache, which either returns an already-loaded value for a given key or atomically
computes or retrieves it using the supplied loader
.
Builds a cache, which either returns an already-loaded value for a given key or atomically
computes or retrieves it using the supplied loader
. If another thread is currently
loading the value for this key, simply waits for that thread to finish and returns its loaded
value. Note that multiple threads can concurrently load values for distinct keys.
the key type of the loader
the value type of the loader
the loader used to obtain new values
the loader used to obtain new values in bulk, called by LoadingCache.getAll
the loader used to obtain already-cached values
a cache having the requested features
Builds a cache which does not automatically load values when keys are requested.
Builds a cache which does not automatically load values when keys are requested.
the key type of the cache
the value type of the cache
a cache having the requested features
Builds a cache, which either returns a scala.concurrent.Future already loaded or currently
computing the value for a given key, or atomically computes the value asynchronously through a
supplied mapping function or the supplied loader
.
Builds a cache, which either returns a scala.concurrent.Future already loaded or currently
computing the value for a given key, or atomically computes the value asynchronously through a
supplied mapping function or the supplied loader
. If the asynchronous computation
fails then the entry will be automatically removed. Note that multiple threads can
concurrently load values for distinct keys.
the key type of the loader
the value type of the loader
the loader used to obtain new values
the loader used to obtain new values in bulk, called by AsyncLoadingCache.getAll
the loader used to obtain already-cached values
a cache having the requested features
java.lang.IllegalStateException
if the value strength is weak or soft
Builds a cache, which either returns a scala.concurrent.Future already loaded or currently
computing the value for a given key, or atomically computes the value asynchronously through a
supplied mapping function or the supplied async loader
.
Builds a cache, which either returns a scala.concurrent.Future already loaded or currently
computing the value for a given key, or atomically computes the value asynchronously through a
supplied mapping function or the supplied async loader
. If the asynchronous
computation fails then the entry will be automatically removed.
Note that multiple threads can concurrently load values for distinct keys.
the key type of the loader
the value type of the loader
the loader used to obtain new values
the loader used to obtain new values in bulk, called by AsyncLoadingCache.getAll
the loader used to obtain already-cached values
java.lang.IllegalStateException
if the value strength is weak or soft
Specifies the executor to use when running asynchronous tasks.
Specifies the executor to use when running asynchronous tasks.
the executor to use for asynchronous execution
this builder instance
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.
the length of time after an entry is last accessed that it should be automatically removed
this builder instance
java.lang.IllegalArgumentException
if duration
is negative
java.lang.IllegalStateException
if the time to idle or time to live was already set
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.
the length of time after an entry is created that it should be automatically removed
this builder instance
java.lang.IllegalArgumentException
if duration
is negative
java.lang.IllegalStateException
if the time to live or time to idle was already set
Sets the minimum total size for the internal hash tables.
Sets the minimum total size for the internal hash tables.
minimum total size for the internal hash tables
this builder instance
java.lang.IllegalArgumentException
if initialCapacity
java.lang.IllegalStateException
if an initial capacity was already set
Specifies the maximum number of entries the cache may contain.
Specifies the maximum number of entries the cache may contain.
the maximum size of the cache
this builder instance
java.lang.IllegalArgumentException
size
is negative
java.lang.IllegalStateException
if a maximum size or weight was already set
Specifies the maximum weight of entries the cache may contain.
Specifies the maximum weight of entries the cache may contain.
This feature cannot be used in conjunction with Scaffeine.maximumSize.
the maximum total weight of entries the cache may contain
this builder instance
java.lang.IllegalArgumentException
if maximumWeight
is negative
java.lang.IllegalStateException
if a maximum weight or size was already set
Enables the accumulation of com.github.benmanes.caffeine.cache.stats.CacheStats during the operation of the cache.
Enables the accumulation of com.github.benmanes.caffeine.cache.stats.CacheStats during the operation of the cache.
a supplier that returns a new com.github.benmanes.caffeine.cache.stats.StatsCounter
this builder instance
Enables the accumulation of com.github.benmanes.caffeine.cache.stats.CacheStats during the operation of the cache.
Enables the accumulation of com.github.benmanes.caffeine.cache.stats.CacheStats during the operation of the cache.
this builder instance
Specifies that active entries are eligible for automatic refresh once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.
Specifies that active entries are eligible for automatic refresh once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.
the length of time after an entry is created that it should be considered stale, and thus eligible for refresh
this builder instance
java.lang.IllegalArgumentException
if duration
is negative
java.lang.IllegalStateException
if the refresh interval was already set
Specifies a listener instance that caches should notify each time an entry is removed for any com.github.benmanes.caffeine.cache.RemovalCause.
Specifies a listener instance that caches should notify each time an entry is removed for any com.github.benmanes.caffeine.cache.RemovalCause.
the key type of the listener
the value type of the listener
a listener that caches should notify each time an entry is removed
this builder instance
java.lang.IllegalStateException
if a removal listener was already set
Specifies that each value (not key) stored in the cache should be wrapped in a java.lang.ref.SoftReference (by default, strong references are used).
Specifies that each value (not key) stored in the cache should be wrapped in a java.lang.ref.SoftReference (by default, strong references are used).
This feature cannot be used in conjunction with Scaffeine.buildAsync.
this builder instance
java.lang.IllegalStateException
if the value strength was already set
Specifies a nanosecond-precision time source for use in determining when entries should be expired or refreshed.
Specifies a nanosecond-precision time source for use in determining when entries should be
expired or refreshed. By default, java.lang.System.nanoTime
is used.
a nanosecond-precision time source
this builder instance
java.lang.IllegalStateException
if a ticker was already set
Specifies that each key (not value) stored in the cache should be wrapped in a java.lang.ref.WeakReference (by default, strong references are used).
Specifies that each key (not value) stored in the cache should be wrapped in a java.lang.ref.WeakReference (by default, strong references are used).
This feature cannot be used in conjunction with Scaffeine.writer.
this builder instance
java.lang.IllegalStateException
if the key strength was already set or the writer was set
Specifies that each value (not key) stored in the cache should be wrapped in a java.lang.ref.WeakReference (by default, strong references are used).
Specifies that each value (not key) stored in the cache should be wrapped in a java.lang.ref.WeakReference (by default, strong references are used).
This feature cannot be used in conjunction with Scaffeine.buildAsync.
this builder instance
java.lang.IllegalStateException
if the value strength was already set
Specifies the weigher to use in determining the weight of entries.
Specifies the weigher to use in determining the weight of entries.
key type of the weigher
value type of the weigher
the weigher to use in calculating the weight of cache entries
this builder instance
java.lang.IllegalArgumentException
if size
is negative
java.lang.IllegalStateException
if a maximum size was already set
Specifies a writer instance that caches should notify each time an entry is explicitly created or modified, or removed for any com.github.benmanes.caffeine.cache.RemovalCause.
Specifies a writer instance that caches should notify each time an entry is explicitly created or modified, or removed for any com.github.benmanes.caffeine.cache.RemovalCause.
This feature cannot be used in conjunction with Scaffeine.weakKeys or Scaffeine.buildAsync.
the key type of the writer
the value type of the writer
a writer instance that caches should notify each time an entry is explicitly created or modified, or removed for any reason
this builder instance
java.lang.IllegalStateException
if a writer was already set or if the key strength is weak