Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.
Apache License 2.0
592 stars 23 forks source link

ktor `CacheStorage` based persistent cache #61

Closed psuzn closed 8 months ago

psuzn commented 9 months ago

This adds a persistent disk cache based on the ktor's CacheStorage. The underlying cache is a disk LRU is a multiplatform port of coil's DiskLruCache (which itself is a port from libcore disklrucache).

HttpCache can be configured as

val httpCacheSize = 1024*1024

KamelConfig {
    imageBitmapCacheSize = DefaultCacheSize
    imageVectorCacheSize = DefaultCacheSize
    svgCacheSize = DefaultCacheSize
    imageBitmapDecoder()
    imageVectorDecoder()
    svgDecoder()
    stringMapper()
    urlMapper()
    uriMapper()
    fileFetcher()
    httpFetcher {
        httpCache(httpCacheSize)
    }
  }
luca992 commented 9 months ago

Amazing, thanks a lot for the contribution! I've been planning to work on #27 for a while, you've beaten me to it 🙌. I'll review this as soon as I can. In the meantime I can publish a snapshot if you want.

psuzn commented 9 months ago

Please take your time to review it. I had to reorganize the codebase to be able to share the common code between different JVM targets and also specify Android-specific things at the same time. I'm open to any suggestions.

luca992 commented 8 months ago

Looks good thanks again! @psuzn