
Enhances persistent caching for HTTP clients using LRU eviction strategy, integrates with Ktor, supports fallback to in-memory cache, and allows custom cache directory configuration.
Kachetor is an easy-to-use Kotlin Multiplatform caching library to support persistent cache with Ktor client.
Supported platforms:
commonMain.dependencies {
implementation("com.vipulasri.kachetor:kachetor:<version>")
}
Don't forget to replace with the latest found on the badges above or the desired version.
Provide the Kachetor instance to the HttpCache plugin and you are good to go.
install(HttpCache) {
publicStorage(KachetorStorage(10 * 1024 * 1024)) // 10MB
}
Kachetor uses platform-specific default cache directories:
context.cacheDir - This refers to the application's cache directory on the Android device.caches directory - This refers to the application's caches directory within the iOS sandbox.Allows storage of the cache in a custom directory:
install(HttpCache) {
publicStorage(KachetorStorage("provide-platform-specific-directory-path", 10 * 1024 * 1024))
}
If Kachetor cannot create a persistent cache due to an issue, it will use an in-memory cache as a fallback.
Copyright 2024 Vipul Asri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Kachetor is an easy-to-use Kotlin Multiplatform caching library to support persistent cache with Ktor client.
Supported platforms:
commonMain.dependencies {
implementation("com.vipulasri.kachetor:kachetor:<version>")
}
Don't forget to replace with the latest found on the badges above or the desired version.
Provide the Kachetor instance to the HttpCache plugin and you are good to go.
install(HttpCache) {
publicStorage(KachetorStorage(10 * 1024 * 1024)) // 10MB
}
Kachetor uses platform-specific default cache directories:
context.cacheDir - This refers to the application's cache directory on the Android device.caches directory - This refers to the application's caches directory within the iOS sandbox.Allows storage of the cache in a custom directory:
install(HttpCache) {
publicStorage(KachetorStorage("provide-platform-specific-directory-path", 10 * 1024 * 1024))
}
If Kachetor cannot create a persistent cache due to an issue, it will use an in-memory cache as a fallback.
Copyright 2024 Vipul Asri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.