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.
- Alphabetic
- By Inheritance
- ExpiringLruCache
- Cache
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ExpiringLruCache(maxCapacity: Long, initialCapacity: Int, timeToLive: Duration, timeToIdle: Duration)
- timeToLive
the time-to-live in millis, zero for disabling ttl-expiration
- timeToIdle
the time-to-idle in millis, zero for disabling tti-expiration
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
-
def
apply(key: Any, genValue: () ⇒ Future[V])(implicit ec: ExecutionContext): Future[V]
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
- ExpiringLruCache → Cache
-
def
apply(key: Any): Keyed
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
ascendingKeys(limit: Option[Int] = None): Iterator[Any]
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
- ExpiringLruCache → Cache
-
def
clear(): Unit
Clears the cache by removing all entries.
Clears the cache by removing all entries.
- Definition Classes
- ExpiringLruCache → Cache
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
get(key: Any): Option[Future[V]]
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
- ExpiringLruCache → Cache
- Annotations
- @tailrec()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
keys: Set[Any]
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
- ExpiringLruCache → Cache
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
remove(key: Any): Option[Future[V]]
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
- ExpiringLruCache → Cache
-
def
size: Int
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
- ExpiringLruCache → Cache
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )