Class

eu.shiftforward.apso.caching

ExpiringLruCache

Related Doc: package caching

Permalink

final class ExpiringLruCache[V] extends Cache[V]

A thread-safe implementation of eu.shiftforward.apso.caching.Cache. The cache has a defined maximum number of entries is can store. After the maximum capacity has been reached new entries cause old ones to be evicted in a last-recently-used manner, i.e. the entries that haven't been accessed for the longest time are evicted first. In addition this implementation optionally supports time-to-live as well as time-to-idle expiration. The former provides an upper limit to the time period an entry is allowed to remain in the cache while the latter limits the maximum time an entry is kept without having been accessed. If both values are non-zero the time-to-live has to be strictly greater than the time-to-idle. Note that expired entries are only evicted upon next access (or by being thrown out by the capacity constraint), so they might prevent gargabe collection of their values for longer than expected.

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

Instance Constructors

  1. new ExpiringLruCache(maxCapacity: Long, initialCapacity: Int, timeToLive: Duration, timeToIdle: Duration)

    Permalink

    timeToLive

    the time-to-live in millis, zero for disabling ttl-expiration

    timeToIdle

    the time-to-idle in millis, zero for disabling tti-expiration

Type Members

  1. class Keyed extends AnyRef

    Permalink
    Definition Classes
    Cache

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. def apply(key: Any, genValue: () ⇒ Future[V])(implicit ec: ExecutionContext): Future[V]

    Permalink

    Returns either the cached Future for the given key or evaluates the given value generating function producing a Future[V].

    Returns either the cached Future for the given key or evaluates the given value generating function producing a Future[V].

    Definition Classes
    ExpiringLruCacheCache
  5. def apply(key: Any): Keyed

    Permalink

    Selects the (potentially non-existing) cache entry with the given key.

    Selects the (potentially non-existing) cache entry with the given key.

    Definition Classes
    Cache
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def ascendingKeys(limit: Option[Int] = None): Iterator[Any]

    Permalink

    Returns a snapshot view of the keys as an iterator, traversing the keys from the least likely to be retained to the most likely.

    Returns a snapshot view of the keys as an iterator, traversing the keys from the least likely to be retained to the most likely. Note that this is not constant time.

    limit

    No more than limit keys will be returned

    Definition Classes
    ExpiringLruCacheCache
  8. def clear(): Unit

    Permalink

    Clears the cache by removing all entries.

    Clears the cache by removing all entries.

    Definition Classes
    ExpiringLruCacheCache
  9. def clone(): AnyRef

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

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def get(key: Any): Option[Future[V]]

    Permalink

    Retrieves the future instance that is currently in the cache for the given key.

    Retrieves the future instance that is currently in the cache for the given key. Returns None if the key has no corresponding cache entry.

    Definition Classes
    ExpiringLruCacheCache
    Annotations
    @tailrec()
  14. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  17. def keys: Set[Any]

    Permalink

    Returns the set of keys in the cache, in no particular order Should return in roughly constant time.

    Returns the set of keys in the cache, in no particular order Should return in roughly constant time. Note that this number might not reflect the exact keys of active, unexpired cache entries, since expired entries are only evicted upon next access (or by being thrown out by a capacity constraint).

    Definition Classes
    ExpiringLruCacheCache
  18. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  21. def remove(key: Any): Option[Future[V]]

    Permalink

    Removes the cache item for the given key.

    Removes the cache item for the given key. Returns the removed item if it was found (and removed).

    Definition Classes
    ExpiringLruCacheCache
  22. def size: Int

    Permalink

    Returns the upper bound for the number of currently cached entries.

    Returns the upper bound for the number of currently cached entries. Note that this number might not reflect the exact number of active, unexpired cache entries, since expired entries are only evicted upon next access (or by being thrown out by a capacity constraint).

    Definition Classes
    ExpiringLruCacheCache
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  24. def toString(): String

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

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

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

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

Inherited from Cache[V]

Inherited from AnyRef

Inherited from Any

Ungrouped