org.feijoas.mango.common.cache

Cache

Related Docs: object Cache | package cache

trait Cache[K, V] extends AnyRef

A semi-persistent mapping from keys to values. Cache entries are manually added using getOrElseUpdate(key, loader) or put(key, value), and are stored in the cache until either evicted or manually invalidated.

Implementations of this interface are expected to be thread-safe, and can be safely accessed by multiple concurrent threads.

Annotations
@Beta()
Since

0.7 (copied from Guava-libraries)

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Cache
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def asMap(): Map[K, V]

    Returns a view of the entries stored in this cache as a thread-safe map.

    Returns a view of the entries stored in this cache as a thread-safe map. Modifications made to the map directly affect the cache.

  2. abstract def getIfPresent(key: K): Option[V]

    Returns an Option which is Some(value) with the value associated with key in this cache, or None if there is no cached value for key.

  3. abstract def getOrElseUpdate(key: K, loader: () ⇒ V): V

    Returns the value associated with key in this cache, obtaining that value from loader if necessary.

    Returns the value associated with key in this cache, obtaining that value from loader if necessary. No observable state associated with this cache is modified until loading completes. This method provides a simple substitute for the conventional if cached, return; otherwise create, cache and return pattern.

    Warning: as with CacheLoader#load, loader must not return null; it may either return a non-null value or throw an exception. The recommend way would be to use a Cache[K, Option[V]] with loader return None instead of throwing an exception.

    This method is equivalent to Cache.get(K, Callable<? extends V>) from the Guava-Libraries.

    Annotations
    @throws( ... )
    Exceptions thrown

    ExecutionError if an error was thrown while loading the value

    ExecutionException if a checked exception was thrown while loading the value

    UncheckedExecutionException if an unchecked exception was thrown while loading the value

  4. abstract def invalidate(key: K): Unit

    Discards any cached value for key key.

  5. abstract def invalidateAll(): Unit

    Discards all entries in the cache.

  6. abstract def put(key: K, value: V): Unit

    Adds a new key/value pair to this cache.

    Adds a new key/value pair to this cache. If the cache previously contained a value associated with the key, the old value is replaced by the value.

    Prefer getOrElseUpdate(key, loader) when using the conventional if cached, return; otherwise create, cache and return pattern.

  7. abstract def size(): Long

    Returns the approximate number of entries in this cache.

  8. abstract def stats(): CacheStats

    Returns a current snapshot of this cache's cumulative statistics.

    Returns a current snapshot of this cache's cumulative statistics. All stats are initialized to zero, and are monotonically increasing over the lifetime of the cache.

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. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def cleanUp(): Unit

    Performs any pending maintenance operations needed by the cache.

    Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def getAllPresent(keys: Traversable[K]): Map[K, V]

    Returns a map of the values associated with keys in this cache.

    Returns a map of the values associated with keys in this cache. The returned map will only contain entries which are already present in the cache.

  11. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  13. def invalidateAll(keys: Traversable[K]): Unit

    Discards any cached values for keys keys.

  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  18. def putAll(kvs: Traversable[(K, V)]): Unit

    Puts all key/value pairs from the specified Traversable to the cache.

    Puts all key/value pairs from the specified Traversable to the cache. The effect of this call is equivalent to that of calling put(key, value) for each (key, value) in the Traversable. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

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

    Definition Classes
    AnyRef
  20. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped