Class/Object

com.stripe.dagon

Cache

Related Docs: object Cache | package dagon

Permalink

sealed class Cache[K, V] extends Serializable

This is a useful cache for memoizing function.

The cache is implemented using a mutable pointer to an immutable map value. In the worst-case, race conditions might cause us to lose cache values (i.e. compute some keys twice), but we will never produce incorrect values.

Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Cache
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def duplicate: Cache[K, V]

    Permalink

    Create a second cache with the same values as this one.

    Create a second cache with the same values as this one.

    The two caches will start with the same values, but will be independently updated.

  7. final def eq(arg0: AnyRef): Boolean

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  11. def getOrElseUpdate(k: K, v: ⇒ V): V

    Permalink

    Given a key, either return a cached value, or compute, store, and return a new value.

    Given a key, either return a cached value, or compute, store, and return a new value.

    This method is what justifies the existence of Cache. Its second parameter (v) is by-name: it will only be evaluated in cases where the key is not cached.

    For example:

    def greet(i: Int): Int = { println("hi") i + 1 }

    val c = Cache.empty[Int, Int] c.getOrElseUpdate(1, greet(1)) // says hi, returns 2 c.getOrElseUpdate(1, greet(1)) // just returns 2

  12. def hashCode(): Int

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

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

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. def reset(): Unit

    Permalink

    Forget all cached keys and values.

    Forget all cached keys and values.

    After calling this method, the resulting cache is equivalent to Cache.empty[K, V].

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

    Permalink
    Definition Classes
    AnyRef
  19. def toMap: Map[K, V]

    Permalink

    Access the currently-cached keys and values as a map.

  20. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped