Cache

org.apache.pekko.http.caching.scaladsl.Cache
@ApiMayChange @DoNotInherit
abstract class Cache[K, V] extends Cache[K, V]

API MAY CHANGE

General interface implemented by all cache implementations.

Attributes

Source
Cache.scala
Graph
Supertypes
trait Cache[K, V]
class Object
trait Matchable
class Any
Self type
Cache[K, V]

Members list

Value members

Abstract methods

def apply(key: K, genValue: () => Future[V]): 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].

Attributes

Source
Cache.scala
override def clear(): Unit

Clears the cache by removing all entries.

Clears the cache by removing all entries.

Attributes

Definition Classes
Cache
Source
Cache.scala
def get(key: K): Option[Future[V]]

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

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

Attributes

Source
Cache.scala
def getOrLoad(key: K, loadValue: K => Future[V]): Future[V]

Returns either the cached Future for the given key, or applies the given value loading function on the key, producing a Future[V].

Returns either the cached Future for the given key, or applies the given value loading function on the key, producing a Future[V].

Attributes

Source
Cache.scala
def keys: Set[K]

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).

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).

Attributes

Source
Cache.scala
def put(key: K, mayBeValue: Future[V])(implicit ex: ExecutionContext): Future[V]

Cache the given future if not cached previously. Or replace the old cached value on successful completion of given future. In case the given future fails, the previously cached value for that key (if any) will remain unchanged.

Cache the given future if not cached previously. Or replace the old cached value on successful completion of given future. In case the given future fails, the previously cached value for that key (if any) will remain unchanged.

Attributes

Source
Cache.scala
override def remove(key: K): Unit

Removes the cache item for the given key.

Removes the cache item for the given key.

Attributes

Definition Classes
Cache
Source
Cache.scala
def size(): Int

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).

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).

Attributes

Source
Cache.scala

Concrete methods

def apply(key: K, f: Promise[V] => Unit): Future[V]

Returns either the cached Future for the key or evaluates the given function which should lead to eventual completion of the promise.

Returns either the cached Future for the key or evaluates the given function which should lead to eventual completion of the promise.

Attributes

Source
Cache.scala
def get(key: K, block: () => V): Future[V]

Returns either the cached Future for the given key or the given value as a Future

Returns either the cached Future for the given key or the given value as a Future

Attributes

Source
Cache.scala
final override def getFuture(key: K, genValue: Creator[CompletionStage[V]]): CompletionStage[V]

Attributes

Definition Classes
Cache
Source
Cache.scala
override def getKeys: Set[K]

Attributes

Definition Classes
Cache
Source
Cache.scala
override def getOptional(key: K): Optional[CompletionStage[V]]

Attributes

Definition Classes
Cache
Source
Cache.scala
override def getOrCreateStrict(key: K, block: Creator[V]): CompletionStage[V]

Returns either the cached CompletionStage for the given key or the given value as a CompletionStage

Returns either the cached CompletionStage for the given key or the given value as a CompletionStage

Attributes

Definition Classes
Cache
Source
Cache.scala
final override def getOrFulfil(key: K, f: Procedure[CompletableFuture[V]]): CompletionStage[V]

Attributes

Definition Classes
Cache
Source
Cache.scala