BlockingContextualCache¶
class BlockingContextualCache<Identifier, Context, Failure, Value>
A blocking cache wrapper, which offers different results depending on the context.
Unlike asynchronous caches, this implementation doesn't allow subscribing to a value to see it change over time.
To instantiate this class, see the blocking helper.
Type Parameters¶
-
Identifier: The identifier used to request from the cache
-
Context: The context which differentiates between cache results.
-
Failure: The possible failures when requesting from the cache.
-
Value: The possible successful values when requesting from the cache.
Functions¶
expire¶
fun expire(id: Identifier)
Tells the cache that the value it stores for id is out-of-date for all contexts, and should be queried again the next time it is requested.
For more information, see ContextualCache.expire.
fun expire(id: Identifier, context: Context)
Tells the cache that the value it stores for id and context is out-of-date for all contexts, and should be queried again the next time it is requested.
For more information, see ContextualCache.expire.
fun expire(ids: Collection<Identifier>)
Tells the cache that the value it stores for the given ids are out-of-date for all contexts, and should be queried again next time they are requested.
For more information, see ContextualCache.expire.
expireAll¶
fun expireAll()
Tells the cache that all values are out-of-date, and should be queried again the next time they are requested.
For more information, see ContextualCache.expire.
expireContextual¶
fun expireContextual(ids: Collection<Pair<Identifier, Context>>)
Tells the cache that the value it stores for the given ids and contexts are out-of-date, and should be queried again next time they are requested.
For more information, see ContextualCache.expire.
get¶
Gets the value associated with id and context in the cache, at the current time.
Unlike ContextualCache.get, this function does not allow subscribing to the value to see its changes over time.
getValue¶
fun <Identifier, Value> BlockingCache<Identifier, Nothing, Value>.getValue(id: Identifier): Value
fun <Identifier, Context, Value> BlockingContextualCache<Identifier, Context, Nothing, Value>.getValue(id: Identifier, context: Context): Value
Convenience function to access a value from infallible caches that are blocking.
For more information, see BlockingCache.get and Cache.get.
set¶
operator fun set(
id: Identifier,
context: Context,
value: Value
)
Forces the cache to accept value as a more recent value for the given id and context than whatever it was previously storing.
For more information, see ContextualCache.update.
update¶
fun update(values: Collection<Triple<Identifier, Context, Value>>)
fun update(vararg values: Triple<Identifier, Context, Value>)
Forces the cache to accept the given values as more recent than their associated identifier than whatever was previously stored.
For more information, see ContextualCache.update.