Package akka.http.caching.scaladsl
Class Cache<K,V>
- java.lang.Object
-
- akka.http.caching.scaladsl.Cache<K,V>
-
-
Constructor Summary
Constructors Constructor Description Cache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract scala.concurrent.Future<V>
apply(K key, scala.Function0<scala.concurrent.Future<V>> genValue)
Returns either the cached Future for the given key or evaluates the given value generating function producing aFuture[V]
.scala.concurrent.Future<V>
apply(K key, scala.Function1<scala.concurrent.Promise<V>,scala.runtime.BoxedUnit> f)
Returns either the cached Future for the key or evaluates the given function which should lead to eventual completion of the promise.abstract void
clear()
Clears the cache by removing all entries.abstract scala.Option<scala.concurrent.Future<V>>
get(K key)
Retrieves the future instance that is currently in the cache for the given key.scala.concurrent.Future<V>
get(K key, scala.Function0<V> block)
Returns either the cached Future for the given key or the given value as a Futurejava.util.concurrent.CompletionStage<V>
getFuture(K key, akka.japi.Creator<java.util.concurrent.CompletionStage<V>> genValue)
Returns either the cached CompletionStage for the given key or evaluates the given value generating function producing a `CompletionStage`. java.util.Set<K>
getKeys()
Returns the set of keys in the cache, in no particular order Should return in roughly constant time.java.util.Optional<java.util.concurrent.CompletionStage<V>>
getOptional(K key)
Retrieves the CompletionStage instance that is currently in the cache for the given key.java.util.concurrent.CompletionStage<V>
getOrCreateStrict(K key, akka.japi.Creator<V> block)
Returns either the cached CompletionStage for the given key or the given value as a CompletionStagejava.util.concurrent.CompletionStage<V>
getOrFulfil(K key, akka.japi.Procedure<java.util.concurrent.CompletableFuture<V>> f)
Returns either the cachedCompletionStage
for the key, or evaluates the given function which should lead to eventual completion of the completable future.abstract scala.concurrent.Future<V>
getOrLoad(K key, scala.Function1<K,scala.concurrent.Future<V>> loadValue)
Returns either the cached Future for the given key, or applies the given value loading function on the key, producing aFuture[V]
.abstract scala.collection.immutable.Set<K>
keys()
Returns the set of keys in the cache, in no particular order Should return in roughly constant time.abstract scala.concurrent.Future<V>
put(K key, scala.concurrent.Future<V> mayBeValue, scala.concurrent.ExecutionContext ex)
Cache the given future if not cached previously.abstract void
remove(K key)
Removes the cache item for the given key.abstract int
size()
Returns the upper bound for the number of currently cached entries.
-
-
-
Method Detail
-
apply
public abstract scala.concurrent.Future<V> apply(K key, scala.Function0<scala.concurrent.Future<V>> genValue)
Returns either the cached Future for the given key or evaluates the given value generating function producing aFuture[V]
.- Parameters:
key
- (undocumented)genValue
- (undocumented)- Returns:
- (undocumented)
-
apply
public scala.concurrent.Future<V> apply(K key, scala.Function1<scala.concurrent.Promise<V>,scala.runtime.BoxedUnit> f)
Returns either the cached Future for the key or evaluates the given function which should lead to eventual completion of the promise.- Parameters:
key
- (undocumented)f
- (undocumented)- Returns:
- (undocumented)
-
clear
public abstract void clear()
Clears the cache by removing all entries.
-
get
public scala.concurrent.Future<V> get(K key, scala.Function0<V> block)
Returns either the cached Future for the given key or the given value as a Future- Parameters:
key
- (undocumented)block
- (undocumented)- Returns:
- (undocumented)
-
get
public abstract scala.Option<scala.concurrent.Future<V>> get(K 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.- Parameters:
key
- (undocumented)- Returns:
- (undocumented)
-
getFuture
public final java.util.concurrent.CompletionStage<V> getFuture(K key, akka.japi.Creator<java.util.concurrent.CompletionStage<V>> genValue)
Description copied from interface:Cache
Returns either the cached CompletionStage for the given key or evaluates the given value generating function producing a `CompletionStage`.
-
getKeys
public java.util.Set<K> getKeys()
Description copied from interface:Cache
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).
-
getOptional
public java.util.Optional<java.util.concurrent.CompletionStage<V>> getOptional(K key)
Description copied from interface:Cache
Retrieves the CompletionStage instance that is currently in the cache for the given key. Returns None if the key has no corresponding cache entry.- Specified by:
getOptional
in interfaceCache<K,V>
-
getOrCreateStrict
public java.util.concurrent.CompletionStage<V> getOrCreateStrict(K key, akka.japi.Creator<V> block)
Returns either the cached CompletionStage for the given key or the given value as a CompletionStage- Specified by:
getOrCreateStrict
in interfaceCache<K,V>
- Parameters:
key
- (undocumented)block
- (undocumented)- Returns:
- (undocumented)
-
getOrFulfil
public final java.util.concurrent.CompletionStage<V> getOrFulfil(K key, akka.japi.Procedure<java.util.concurrent.CompletableFuture<V>> f)
Description copied from interface:Cache
Returns either the cachedCompletionStage
for the key, or evaluates the given function which should lead to eventual completion of the completable future.- Specified by:
getOrFulfil
in interfaceCache<K,V>
-
getOrLoad
public abstract scala.concurrent.Future<V> getOrLoad(K key, scala.Function1<K,scala.concurrent.Future<V>> loadValue)
Returns either the cached Future for the given key, or applies the given value loading function on the key, producing aFuture[V]
.- Parameters:
key
- (undocumented)loadValue
- (undocumented)- Returns:
- (undocumented)
-
keys
public abstract scala.collection.immutable.Set<K> keys()
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:
- (undocumented)
-
put
public abstract scala.concurrent.Future<V> put(K key, scala.concurrent.Future<V> mayBeValue, scala.concurrent.ExecutionContext ex)
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.- Parameters:
key
- (undocumented)mayBeValue
- (undocumented)ex
- (undocumented)- Returns:
- (undocumented)
-
remove
public abstract void remove(K key)
Removes the cache item for the given key.
-
size
public abstract int size()
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).
-
-