CachedTiledFeatureSource

Cache-first decorator over a TiledFeatureSource. On fetchTile:

  1. Read store for (z, x, y). Hit → return cached flow (an empty flow means the tile is cached with zero features — the negative-cache sentinel); if the tile is older than the store's eviction CachePolicy.staleAfter, also kick a background refresh (stale-while-revalidate — see maybeRevalidate).

  2. Miss → fetch from inner, write-through, return.

Constructors

Link copied to clipboard
constructor(inner: TiledFeatureSource?, store: FeatureStore, revalidationScope: CoroutineScope = GlobalScope)

Properties

Link copied to clipboard
open override val cacheInfo: CachedSourceInfo?
Link copied to clipboard

The backing store. Exposed for bulk-download flows that persist store-level metadata (e.g. the downloaded-region bounding sector).

Link copied to clipboard
open override var isCacheOnly: Boolean

When true, fetchTile never calls inner — cache hits served, cache misses return null. Mirrors CachedTileSource.isCacheOnly.

Link copied to clipboard

The wrapped upstream tiled-feature source. Exposed for rebind flows — attachCache extractors peel this off when the layer is already cache-attached.

Link copied to clipboard
open override var onTileRevalidated: (z: Int, x: Int, y: Int) -> Unit?

Invoked (off the render thread) after a stale tile is re-downloaded and replaced, so the render layer can drop its in-memory copy and reload the fresh rows.

Functions

Link copied to clipboard
suspend fun bulkFetchTile(z: Int, x: Int, y: Int, sector: Sector, overrideCache: Boolean = false): Flow<CachedFeatureRow>?

Bulk-download counterpart to fetchTile — used by "save a region for offline use" flows. Ignores isCacheOnly (bulk always allows network) and writes the FULL fetch through to store. The write-through happens when the returned flow is collected, so the caller must drain it. Returns null when there's nothing to fetch (no rows / no network source).

Link copied to clipboard
open fun close()

Release any resources held by the source (HTTP client, etc.). Idempotent default no-op.

Link copied to clipboard
open suspend override fun fetchTile(z: Int, x: Int, y: Int, sector: Sector): Flow<CachedFeatureRow>?
Link copied to clipboard
open suspend override fun tryReadCachedTile(z: Int, x: Int, y: Int, sector: Sector): Flow<CachedFeatureRow>?

Cache-only fast-path read for (z, x, y). Default returns null — a plain network source has no cache to consult. Cache-backed sources override to read their store without going through the network-fetch concurrency budget. Empty flow is the negative-cache sentinel ("fetched, no features"); null is a true miss.