RetrostashKtorCache

Direct cache control for the Ktor adapter — peek, update, invalidate*, clearAll. All methods are suspend; call from any coroutine. Mirror surface of RetrostashOkHttpCache but uses scopeName: String instead of Class<*> for KMP compatibility, and stores raw bytes (no envelope — Ktor doesn't synthesize HTTP responses on cache hit, the plugin hands the bytes back via RetrostashCachedPayloadKey).

Full guidance — including how to source the bytes for updateQuery from typed responses and the converter-agnostic philosophy behind that — lives in the README: Cache API.

Obtained via RetrostashKtorRuntime.cache.

Functions

Link copied to clipboard
suspend fun clearAll()

Drops every entry from the underlying store.

Link copied to clipboard
suspend fun invalidateQuery(scopeName: String, template: String, bindings: Map<String, Any?>, bodyBytes: ByteArray? = null): String?

Resolves template against bindings in the namespace of scopeName and invalidates the resulting cache key. Returns the resolved key, or null if any placeholder couldn't be filled.

Link copied to clipboard
suspend fun invalidateQueryKey(key: String)

Invalidates a single template/key directly, bypassing annotation extraction.

Link copied to clipboard
suspend fun invalidateTag(tag: String)

Removes every cached entry whose tag set contains tag. The tag must be the resolved value (e.g. "article:concept123").

Link copied to clipboard
suspend fun invalidateTags(tags: List<String>)

Bulk version of invalidateTag. Blank values skipped.

Link copied to clipboard
suspend fun peekQuery(scopeName: String, template: String, bindings: Map<String, Any?>, bodyBytes: ByteArray? = null): ByteArray?

Returns the cached payload bytes for a query, or null if no entry, the placeholders couldn't be resolved, or the store call timed out. Decode with whatever serializer you used to write the entry.

Link copied to clipboard
suspend fun updateQuery(scopeName: String, template: String, bindings: Map<String, Any?>, payload: ByteArray, 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. Returns the resolved cache key, or null if any placeholder couldn't be resolved.