org.feijoas.mango.common.cache

CacheLoader

Related Docs: object CacheLoader | package cache

trait CacheLoader[K, V] extends (K) ⇒ V

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

This class should be when bulk retrieval is significantly more efficient than many individual lookups. Otherwise the CacheLoader companion object can be used to create a CacheLoader[K,V] from a function K => V. For example

val createExpensiveGraph: Key => Graph = ...
val loader: CacheLoader[Key,Graph] = CacheLoader.from(createExpensiveGraph)

Alternatively the function K => V can be passed to CacheBuilder directly.

Since

0.7 (copied from Guava-libraries)

Linear Supertypes
(K) ⇒ V, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CacheLoader
  2. Function1
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def load(key: K): V

    Computes or retrieves the value corresponding to key.

    Computes or retrieves the value corresponding to key.

    key

    the non-null key whose value should be loaded

    returns

    the value associated with key; must not be null

    Annotations
    @throws( classOf[Exception] )
    Exceptions thrown

    Exception if unable to load the result

    InterruptedException if this method is interrupted. InterruptedException is treated like any other Exception in all respects except that, when it is caught, the thread's interrupt status is set

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (V) ⇒ A): (K) ⇒ A

    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def apply(key: K): V

    Computes or retrieves the value corresponding to key.

    Computes or retrieves the value corresponding to key. Simply forwards to load(K).

    Definition Classes
    CacheLoader → Function1
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def compose[A](g: (A) ⇒ K): (A) ⇒ V

    Definition Classes
    Function1
    Annotations
    @unspecialized()
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. def loadAll(keys: Traversable[K]): Map[K, V]

    Computes or retrieves the values corresponding to keys.

    Computes or retrieves the values corresponding to keys. This method is called by LoadingCache#getAll.

    If the returned map doesn't contain all requested keys then the entries it does contain will be cached, but getAll will throw an exception. If the returned map contains extra keys not present in keys then all returned entries will be cached, but only the entries for keys will be returned from getAll.

    This method should be overridden when bulk retrieval is significantly more efficient than many individual lookups. Note that LoadingCache#getAll will defer to individual calls to LoadingCache#get if this method is not overridden.

    keys

    the unique, non-null keys whose values should be loaded

    returns

    an immutable map from each key in keys to the value associated with that key; may not contain null values

    Exceptions thrown

    Exception if unable to load the result

    InterruptedException if this method is interrupted. InterruptedException is treated like any other Exception in all respects except that, when it is caught, the thread's interrupt status is set

  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. def reload(key: K, oldValue: V): Future[V]

    Computes or retrieves a replacement value corresponding to an already-cached key.

    Computes or retrieves a replacement value corresponding to an already-cached key. This method is called when an existing cache entry is refreshed by CacheBuilder#refreshAfterWrite, or through a call to LoadingCache#refresh.

    This implementation synchronously delegates to #load. It is recommended that it be overridden with an asynchronous implementation when using CacheBuilder#refreshAfterWrite.

    Note: all exceptions thrown by this method will be logged and then swallowed.

    key

    the non-null key whose value should be loaded

    oldValue

    the non-null old value corresponding to key

    returns

    the future new value associated with key; must not be null, must not return null

    Annotations
    @throws( classOf[Exception] )
    Exceptions thrown

    Exception if unable to reload the result

    InterruptedException if this method is interrupted. InterruptedException is treated like any other Exception in all respects except that, when it is caught, the thread's interrupt status is set

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  21. def toString(): String

    Definition Classes
    Function1 → AnyRef → Any
  22. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from (K) ⇒ V

Inherited from AnyRef

Inherited from Any

Ungrouped