RetrostashOkHttpCache

Direct cache control for the OkHttp / Retrofit adapter — peek, update, invalidate*, clearAll. Methods are blocking; each call wraps a single coroutine via runBlocking so Android consumers don't have to manage a coroutine scope.

Entries are wrapped in a synthetic CachedHttpEnvelope on updateQuery (status 200, the supplied content-type, no headers) so they're indistinguishable from interceptor-written entries on read-back.

Full guidance — including how to source the bytes for updateQuery from Response<MyDto> / Response<String> and the converter-agnostic philosophy behind that — lives in the README: Cache API.

Obtained via RetrostashOkHttpBridge.cache.

Functions

Link copied to clipboard
fun clearAll()

Drops every entry from the underlying store.

Link copied to clipboard
fun invalidateQuery(apiClass: ERROR CLASS: Symbol not found for Class<*>, template: String, bindings: Map<String, Any?>, bodyBytes: ByteArray? = null): String?

Resolves template against bindings in the namespace of apiClass and invalidates the resulting cache key. Returns the resolved key, or null if any placeholder could not be filled.

Link copied to clipboard

Invalidates a single template/key directly, bypassing annotation extraction. Returns true if a non-blank key was scheduled for invalidation.

Link copied to clipboard

Removes every cached entry whose tag set contains tag. The tag must be the resolved value (e.g. "article:concept123"). Returns true if a non-blank tag was scheduled.

Link copied to clipboard
fun invalidateTags(vararg tags: String): Boolean

Bulk version of invalidateTag. Blank values are skipped.

Link copied to clipboard
fun peekQuery(apiClass: ERROR CLASS: Symbol not found for Class<*>, template: String, bindings: Map<String, Any?>, bodyBytes: ByteArray? = null): ByteArray?

Returns the cached payload for a query, or null if no entry, the placeholders couldn't be resolved, or the store call timed out. The returned bytes are envelope-unwrapped — the same body bytes the network would have returned.

Link copied to clipboard
fun updateQuery(apiClass: ERROR CLASS: Symbol not found for Class<*>, template: String, bindings: Map<String, Any?>, payload: ByteArray, contentType: String? = null, maxAgeMs: Long? = null, tags: List<String>? = null, bodyBytes: ByteArray? = null): String?

PATCH-style write. Persists payload under the resolved cache key for the given query, wrapped in a synthetic 200 OK envelope. Returns the resolved cache key, or null if any placeholder in template couldn't be resolved.