RetrostashOkHttpBridge

class RetrostashOkHttpBridge(val store: RetrostashStore, config: RetrostashOkHttpConfig = RetrostashOkHttpConfig(), keyResolver: CoreKeyResolver = CoreKeyResolver(), val engine: RetrostashEngine = RetrostashEngine( store = store, keyResolver = keyResolver, timeoutMs = config.timeoutMs, ))

Top-level OkHttp/Retrofit integration object. Holds the RetrostashEngine + store and installs the two interceptors needed to read/write the cache:

  • RetrostashOkHttpHandleInterceptor (application interceptor) — exposes the bridge so callers can recover it via from.

  • RetrostashOkHttpInterceptor (network interceptor) — actual cache logic.

For Android, prefer the convenience factory RetrostashOkHttpAndroid.install(builder, context) which constructs a Context-backed disk store automatically.

Pure-JVM consumers construct the bridge directly with their own RetrostashStore:

val bridge = RetrostashOkHttpBridge(
store = InMemoryRetrostashStore(),
config = RetrostashOkHttpConfig(logger = ::println),
)
val client = OkHttpClient.Builder().also(bridge::install).build()

Direct cache control — peek, update, invalidate, clear — lives on cache. See RetrostashOkHttpCache and the README's Cache API section.

Constructors

Link copied to clipboard
constructor(store: RetrostashStore, config: RetrostashOkHttpConfig = RetrostashOkHttpConfig(), keyResolver: CoreKeyResolver = CoreKeyResolver(), engine: RetrostashEngine = RetrostashEngine( store = store, keyResolver = keyResolver, timeoutMs = config.timeoutMs, ))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Direct cache surface — peekQuery, updateQuery, invalidateQuery*, invalidateTag(s), clearAll.

Link copied to clipboard

Underlying transport-agnostic engine. Exposed for advanced wiring.

Link copied to clipboard

Backing cache store.

Functions

Link copied to clipboard
fun install(builder: ERROR CLASS: Symbol not found for OkHttpClient.Builder): ERROR CLASS: Symbol not found for OkHttpClient.Builder

Adds Retrostash's interceptors to builder. Returns builder for chaining.