KStore


A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialization and kotlinx.io.
Inspired by RxStore
Features
- 🔒 Read-write locks; with a mutex FIFO lock
- 💾 In-memory caching; read once from disk and reuse
- 📬 Default values; no file? no problem!
- 🚚 Migration support; moving shop? take your data with you
- 🚉 Multiplatform!
Installation
KStore is published on Maven Central. Latest version 
repositories {
mavenCentral()
maven("https://central.sonatype.com/repository/maven-snapshots/")
}
kstore = { module = "io.github.xxfast:kstore", version.ref = "kstore" }
kstore-file = { module = "io.github.xxfast:kstore-file", version.ref = "kstore" }
kstore-storage = { module = "io.github.xxfast:kstore-storage", version.ref = "kstore" }
Depending on your target platforms, you will need to add platform configurations here
At a glance
import kotlin.io.path.Path
import kotlinx.serialization.Serializable
@Serializable data class Pet(val name: String, age: )
store: KStore<Pet> = storeOf(file = Path())
mylo: Pet? = store.()
store.(mylo)
store.update { pet: Pet? ->
pet?.copy(age = pet.age + )
}
store.delete()
pets: Flow<Pet?> = store.updates
Installation and Usage
Documentation here
API Reference here
Licence
Copyright 2023-2026 Isuru Rajapakse
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this except compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.