Skip to content
Exposed docs2.0

Exposed Ktor Cache Adapter

Latest stable Based on Exposed release 2.0.0

Backend-neutral Ktor readiness contributors for caller-owned Exposed cache repositories and snapshot failure buffers.

Cache health must be observable without turning a readiness request into database, network, or blocking work.

Use this adapter when a Ktor service wants an O(1) in-memory view of JDBC, R2DBC, snapshot, or custom cache health.

implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k.exposed:bluetape4k-exposed-ktor-cache")

ExposedKtorCacheContributor sanitizes finite status and measurements. A contributor is caller-owned, side-effect-free, cancellation-cooperative, and bounded to a low-cardinality component name.

val config = ExposedKtorCacheReadinessConfig(listOf(
ExposedKtorCacheContributor.custom("local-cache") { ExposedKtorCacheStatus.UP },
))
val probes = exposedKtorCacheReadinessProbes(config)
route.bluetape4kExposedHealthRoutes(probes)
  • Use jdbcRepository, r2dbcRepository, snapshot, or custom contributors.
  • Wrap contributors with ExposedKtorCacheReadinessConfig.
  • Convert the immutable configuration with exposedKtorCacheReadinessProbes.

Read an existing health snapshot; do not perform I/O in a supplier. Use stable component names and let the application own cache invalidation and shutdown.

The adapter depends on core and the Exposed cache foundation. JDBC Caffeine and R2DBC Caffeine persistence implementations remain optional.

Configure one to sixteen unique contributors. Queue and snapshot measurements are non-negative; unavailable values use NaN and are never coerced to zero.

Supplier exceptions become DOWN, cancellation follows the request context, and invalid component names or measurements fail at configuration time. Raw cache keys, URLs, SQL, and causes are not returned.

Cache probes run sequentially under the core shared deadline. Export core readiness metrics and monitor the cache repository’s own lifecycle report separately.

Test O(1) snapshot conversion, negative-value rejection, supplier cancellation, deadline expiry, duplicate components, and sanitized responses.

No selective cache workshop is published in this 2.0.0 release line.

The contributor contract does not make blocking or backend-I/O suppliers safe. Applications must supply a true in-memory observer.