xxfast / KStore

A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and kotlinx.io
https://xxfast.github.io/KStore/
Apache License 2.0
540 stars 18 forks source link

Migrate to kotlinx-io #116

Closed xxfast closed 3 months ago

xxfast commented 3 months ago

Builds on top of @mani1232's #112

github-actions[bot] commented 3 months ago

Code Coverage

File Coverage [87.10%] :white_check_mark:
kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/FileCodec.kt 78.57% :x:
kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/KStore.kt 76.92% :x:
kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/extensions/KListStore.kt 83.33% :white_check_mark:
kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/extensions/KVersionedStore.kt 96.55% :white_check_mark:
Total Project Coverage 92.16% :white_check_mark:
xxfast commented 3 months ago

Hi @mani1232 & @8cAyqpVKio

I've added a new overloaded factory method that lets you provide a custom codec (if you want your custom file format) so this should theoretically let you use a format other than JSON)

Again, this is out of scope for now but should unblock anyone who wants to use other unstable serialiser formats

mani1232 commented 3 months ago

I have a couple questions: Does it make sense to save not immediately, but every X minutes? image And will it be possible to set your own compression algorithm image

xxfast commented 3 months ago

Do you mean to schedule the writes to the disk?

KStore API for writes/reads all suspended so that it will block whichever coroutine it is invoked from. This is by design.

There's couple advantages for this approach

However, any asynchronous behaviour can still be implemented on top of this - with coroutines.