Skip to content

opensavvy.cache

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

Cache

interface Cache<Identifier, Failure, Value>

Stores information temporarily to avoid unneeded network requests.

ExperimentalCacheApi

@RequiresOptIn(message = "This API has not been stabilized yet. We expect to make breaking changes to it in the future. If you have some ideas of how it could be used, please contact us so we can take it into account.")
annotation class ExperimentalCacheApi

InfallibleCache

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

Functions

batchingCache

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

cache

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

Cache implementation which calls a given transform suspending function.

Cache implementation which calls a given transform suspending function.