Repository navigation
feat(cache): expose public CacheStorage factories for Ktor HttpCache - #76
Merged
Merged
Conversation
…y for Ktor HttpCache
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OkioCacheStorage(...)(stable) andKotlinxIoCacheStorage(...)(experimental) as public factories returning Ktor'sCacheStorage.HttpCache { publicStorage(...) }, without thePersistentCacheplugin, thesharedfacade or, for the kotlinx-io backend, Okio.Linked issue
Closes #75
Type of change
Changes
cache-coreCacheStorageDefaults(DIRECTORY,MAX_SIZE,TTL) behind@InternalPersistentCacheApi, used byPersistentCacheConfigand both factoriescache-okioOkioCacheStorage(directory, maxSize, ttl, directoryProvider, fileSystem, clock), stable APIcache-kotlinx-ioKotlinxIoCacheStorage(...)with the same parameters, annotated@ExperimentalKotlinxIoCachecache-okioandcache-kotlinx-ionow declareapi(ktor-client-core)because the factories return Ktor'sCacheStoragedocs/STORAGE.md, CHANGELOGDesign decisions (from #75):
CacheFileSystem,CacheFileMetadataandFileCacheStoragestay behind the ERROR-level@InternalPersistentCacheApi. The factories do not leak it in their signatures.Compatibility
apiDumpbaselines changed for the new declarations (JVM dumps forcache-okioandcache-kotlinx-io; JVM and klib dumps forcache-core).cache-okioorcache-kotlinx-ionow receivektor-client-coretransitively.PersistentCachebehaviour and public API are unchanged.Test plan
./gradlew assemble check apiCheckpasses locally (macOS arm64, 6 GB Gradle heap)HttpCacheandMockEnginewith the factory directly: a second client on a fresh storage reads from disk with zero engine requests, defaults, custom directory, ttl, and maxSize evictiontestAndroidHostTest) and iOS simulator;CacheStorageDefaultsTestadds 2 tests incache-coreChecklist
status:approved)./gradlew check apiCheckpasses locally./gradlew apiDumpNotes for reviewers
PersistentCachedoes not call the backend factories, becausecache-corecannot depend on the backends. It shares theFileCacheStoragealgorithm and the defaults, so there is one code path for caching behaviour, but not one construction path. [Task]: Expose a public CacheStorage factory usable with Ktor HttpCache #75 asked for the plugin to build through the same factory; this is the closest the module layout allows.cache-okioandcache-kotlinx-ioonly have JVM API baselines (no.klib.api), soapiCheckguards only the JVM surface of the new factories.OkioCacheStorage; for the defaults object andKotlinxIoCacheStoragethe implementation was written before the failing run. The kotlinx-io tests mirror the Okio ones.