Package-level declarations

Reactive key-value store algorithms represented by the Cache interface.

For convenience, adapters are provided:

  • cache caches calls to any suspend function,

  • batchingCache intercepts subsequent cache requests and batches them into a single larger request.

The following cache layers are available:

  • cachedInMemory stores results in-memory. When values are updated, it continues to show the old values while the new ones are being fetched,

  • expireAfter expires the values stored by the previous layer after some time has passed.

Types

Link copied to clipboard

Stores information temporarily to avoid unneeded network requests.

Link copied to clipboard
annotation class ExperimentalCacheApi
Link copied to clipboard

Stores information temporarily to avoid unneeded network requests, with no error strategy.

Functions

Link copied to clipboard

Cache implementation which collects cache requests into batches which are queried at the same time.

Link copied to clipboard
@JvmName(name = "infallibleCache")
fun <Identifier, Value> cache(transform: suspend (Identifier) -> Value): InfallibleCache<Identifier, Value>

Cache implementation which calls a given transform suspending function.

Link copied to clipboard
fun <Identifier, Failure, Value : Any> Cache<Identifier, Failure, Value>.cachedInBrowserStorage(storage: Storage, keyPrefix: String, serializeIdentifier: (Identifier) -> String?, serializeValue: (Value) -> String?, deserializeValue: (String) -> Value?): Cache<Identifier, Failure, Value>

In-browser Cache layer.

Link copied to clipboard
fun <Identifier, Failure, Value : Any> Cache<Identifier, Failure, Value>.cachedInLocalStorage(keyPrefix: String, serializeIdentifier: (Identifier) -> String?, serializeValue: (Value) -> String?, deserializeValue: (String) -> Value?): Cache<Identifier, Failure, Value>

In-browser Cache implementation that is shared between tabs and persists when the browser is closed.

Link copied to clipboard
Link copied to clipboard
fun <Identifier, Failure, Value : Any> Cache<Identifier, Failure, Value>.cachedInSessionStorage(keyPrefix: String, serializeIdentifier: (Identifier) -> String?, serializeValue: (Value) -> String?, deserializeValue: (String) -> Value?): Cache<Identifier, Failure, Value>

In-browser Cache implementation that is cleared when the tab is closed.

Link copied to clipboard

Age-based Cache expiration strategy.