DocTranslationCache

class DocTranslationCache(cacheDir: Path, fileSystem: FileSystem, maxCacheSizeBytes: Long = MAX_CACHE_SIZE_BYTES)(source)

File-based cache for ML Kit translated markdown pages.

Cache key: {pageId}#{locale}#{md5(sourceContent)} When the English source changes, the md5 changes and the old cache entry becomes stale. Eviction by oldest-access at maxCacheSizeBytes (default 50MB).

Constructors

Link copied to clipboard
constructor(cacheDir: Path, fileSystem: FileSystem, maxCacheSizeBytes: Long = MAX_CACHE_SIZE_BYTES)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun clear()

Remove all cached translations.

Link copied to clipboard
suspend fun get(pageId: String, locale: String, sourceHash: String): String?

Get a cached translation, or null if not cached or stale.

Link copied to clipboard
suspend fun put(pageId: String, locale: String, sourceHash: String, translatedMarkdown: String)

Store a translated page in the cache. Evicts old entries if over size limit.

Link copied to clipboard
suspend fun sizeBytes(): Long

Total bytes used by the cache.