case class Scaffeine[K, V](underlying: Caffeine[K, V]) extends Product with Serializable
- Alphabetic
- By Inheritance
- Scaffeine
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def build[K1 <: K, V1 <: V](loader: (K1) => V1, allLoader: Option[(Iterable[K1]) => Map[K1, V1]] = None, reloadLoader: Option[(K1, V1) => V1] = None): LoadingCache[K1, V1]
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.- K1
the key type of the loader
- V1
the value type of the loader
- loader
the loader used to obtain new values
- allLoader
the loader used to obtain new values in bulk, called by LoadingCache.getAll(keys:Iterable[K])*
- reloadLoader
the loader used to obtain already-cached values
- returns
a cache having the requested features
- def build[K1 <: K, V1 <: V](): Cache[K1, V1]
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.
- K1
the key type of the cache
- V1
the value type of the cache
- returns
a cache having the requested features
- def buildAsync[K1 <: K, V1 <: V](loader: (K1) => V1, allLoader: Option[(Iterable[K1]) => Map[K1, V1]] = None, reloadLoader: Option[(K1, V1) => V1] = None): AsyncLoadingCache[K1, V1]
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.- K1
the key type of the loader
- V1
the value type of the loader
- loader
the loader used to obtain new values
- allLoader
the loader used to obtain new values in bulk, called by AsyncLoadingCache.getAll(keys:Iterable[K])*
- reloadLoader
the loader used to obtain already-cached values
- returns
a cache having the requested features
- Exceptions thrown
java.lang.IllegalStateException
if the value strength is weak or soft
- def buildAsync[K1 <: K, V1 <: V](): AsyncCache[K1, V1]
Builds a cache which does not automatically load values when keys are requested unless a mapping function is provided.
Builds a cache which does not automatically load values when keys are requested unless a mapping function is provided. The returned scala.concurrent.Future may be already loaded or currently computing the value for a given key. If the asynchronous computation fails value then the entry will be automatically removed. Note that multiple threads can concurrently load values for distinct keys.
- K1
the key type of the cache
- V1
the value type of the cache
- returns
a cache having the requested features
- def buildAsyncFuture[K1 <: K, V1 <: V](loader: (K1) => Future[V1], allLoader: Option[(Iterable[K1]) => Future[Map[K1, V1]]] = None, reloadLoader: Option[(K1, V1) => Future[V1]] = None): AsyncLoadingCache[K1, V1]
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.- K1
the key type of the loader
- V1
the value type of the loader
- loader
the loader used to obtain new values
- allLoader
the loader used to obtain new values in bulk, called by AsyncLoadingCache.getAll(keys:Iterable[K])*
- reloadLoader
the loader used to obtain already-cached values
- Exceptions thrown
java.lang.IllegalStateException
if the value strength is weak or soft
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def evictionListener[K1 <: K, V1 <: V](evictionListener: (K1, V1, RemovalCause) => Unit): Scaffeine[K1, V1]
Specifies a listener instance that caches should notify each time an entry is evicted.
Specifies a listener instance that caches should notify each time an entry is evicted.
- K1
the key type of the listener
- V1
the value type of the listener
- evictionListener
a listener that caches should notify each time an entry is being automatically removed due to eviction
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if a removal listener was already set
- def executor(executor: Executor): Scaffeine[K, V]
Specifies the executor to use when running asynchronous tasks.
Specifies the executor to use when running asynchronous tasks.
- executor
the executor to use for asynchronous execution
- returns
this builder instance
- def expireAfter[K1 <: K, V1 <: V](create: (K1, V1) => FiniteDuration, update: (K1, V1, FiniteDuration) => FiniteDuration, read: (K1, V1, FiniteDuration) => FiniteDuration): Scaffeine[K1, V1]
Specifies that each entry should be automatically removed from the cache once a 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 duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.
- K1
the key type of the expiry.
- V1
the value type of the expiry.
- create
the length of time an entry should be automatically removed from the cache after the entry's creation.
- update
the length of time an entry should be automatically removed from the cache after the replacement of it's value.
- read
the length of time an entry should be automatically removed from the cache after the entry's last read.
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if expiration was already set or used with expiresAfterAccess or expiresAfterWrite.
- def expireAfterAccess(duration: FiniteDuration): Scaffeine[K, V]
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.
- duration
the length of time after an entry is last accessed that it should be automatically removed
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
ifduration
is negativejava.lang.IllegalStateException
if the time to idle or time to live was already set
- def expireAfterWrite(duration: FiniteDuration): Scaffeine[K, V]
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.
- duration
the length of time after an entry is created that it should be automatically removed
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
ifduration
is negativejava.lang.IllegalStateException
if the time to live or time to idle was already set
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def initialCapacity(initialCapacity: Int): Scaffeine[K, V]
Sets the minimum total size for the internal hash tables.
Sets the minimum total size for the internal hash tables.
- initialCapacity
minimum total size for the internal hash tables
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
if initialCapacityjava.lang.IllegalStateException
if an initial capacity was already set
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def maximumSize(maximumSize: Long): Scaffeine[K, V]
Specifies the maximum number of entries the cache may contain.
Specifies the maximum number of entries the cache may contain.
- maximumSize
the maximum size of the cache
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
size
is negativejava.lang.IllegalStateException
if a maximum size or weight was already set
- def maximumWeight(maximumWeight: Long): Scaffeine[K, V]
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.
- maximumWeight
the maximum total weight of entries the cache may contain
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
ifmaximumWeight
is negativejava.lang.IllegalStateException
if a maximum weight or size was already set
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def recordStats[C <: StatsCounter](statsCounterSupplier: () => C): Scaffeine[K, V]
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.
- statsCounterSupplier
a supplier that returns a new com.github.benmanes.caffeine.cache.stats.StatsCounter
- returns
this builder instance
- def recordStats(): Scaffeine[K, V]
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.
- returns
this builder instance
- def refreshAfterWrite(duration: FiniteDuration): Scaffeine[K, V]
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.
- duration
the length of time after an entry is created that it should be considered stale, and thus eligible for refresh
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
ifduration
is negativejava.lang.IllegalStateException
if the refresh interval was already set
- def removalListener[K1 <: K, V1 <: V](removalListener: (K1, V1, RemovalCause) => Unit): Scaffeine[K1, V1]
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.
- K1
the key type of the listener
- V1
the value type of the listener
- removalListener
a listener that caches should notify each time an entry is removed
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if a removal listener was already set
- def scheduler(scheduler: Scheduler): Scaffeine[K, V]
Specifies the scheduler to use when scheduling routine maintenance based on an expiration event.
Specifies the scheduler to use when scheduling routine maintenance based on an expiration event. This augments the periodic maintenance that occurs during normal cache operations to allow for the prompt removal of expired entries regardless of whether any cache activity is occurring at that time. By default the scheduler is disabled.
- scheduler
the scheduler that submits a task to the Scaffeine.executor* after a given delay
- returns
this builder instance
- def softValues(): Scaffeine[K, V]
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[K1<:K,V1<:V]()*.
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if the value strength was already set
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def ticker(ticker: Ticker): Scaffeine[K, V]
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.- ticker
a nanosecond-precision time source
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if a ticker was already set
- val underlying: Caffeine[K, V]
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def weakKeys(): Scaffeine[K, V]
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).
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if the key strength was already set or the writer was set
- def weakValues(): Scaffeine[K, V]
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[K1<:K,V1<:V]()*.
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalStateException
if the value strength was already set
- def weigher[K1 <: K, V1 <: V](weigher: (K1, V1) => Int): Scaffeine[K1, V1]
Specifies the weigher to use in determining the weight of entries.
Specifies the weigher to use in determining the weight of entries.
- K1
key type of the weigher
- V1
value type of the weigher
- weigher
the weigher to use in calculating the weight of cache entries
- returns
this builder instance
- Exceptions thrown
java.lang.IllegalArgumentException
ifsize
is negativejava.lang.IllegalStateException
if a maximum size was already set