Skip to content

ktor CacheStorage based persistent cache#61

Merged
luca992 merged 6 commits into
Kamel-Media:mainfrom
psuzn:sp/persistent-cache
Oct 15, 2023
Merged

ktor CacheStorage based persistent cache#61
luca992 merged 6 commits into
Kamel-Media:mainfrom
psuzn:sp/persistent-cache

Conversation

@psuzn

@psuzn psuzn commented Sep 20, 2023

Copy link
Copy Markdown
Contributor

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

luca992 commented Sep 20, 2023

Copy link
Copy Markdown
Member

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

psuzn commented Sep 21, 2023

Copy link
Copy Markdown
Contributor Author

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 luca992 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Just have a few questions basically.

Comment thread kamel-image/build.gradle.kts Outdated
Comment thread kamel-core/src/jsMain/kotlin/io/kamel/core/cache/httpCache.js.kt
Comment thread kamel-core/build.gradle.kts Outdated
Comment thread kamel-core/build.gradle.kts
@psuzn psuzn requested a review from luca992 October 15, 2023 14:23
@luca992

luca992 commented Oct 15, 2023

Copy link
Copy Markdown
Member

Looks good thanks again! @psuzn

@luca992 luca992 merged commit e8c2f5f into Kamel-Media:main Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants