evictCacheFiles

suspend fun evictCacheFiles(context: Context, prefix: String, ttlMs: Long, maxSizeBytes: Long)

Evicts cached files matching prefix based on a time-to-live and a total size cap.

  1. Deletes every file whose lastModified is older than ttlMs milliseconds.

  2. If the remaining files exceed maxSizeBytes in total, deletes the oldest files first until the total drops below the cap.

Parameters

context

Android context for cache directory access

prefix

Filename prefix that identifies files subject to eviction

ttlMs

Maximum age in milliseconds; older files are always deleted

maxSizeBytes

Soft size cap in bytes; exceeded only temporarily until the next eviction pass