The epsilon-datastore module provides a multiplatform persistent key-value storage solution built on top of Jetpack DataStore.
This module is useful when shared code needs a consistent persistence abstraction across supported platforms.
StoreKey to define keys and expected value types.The main class for interacting with the underlying DataStore. It allows you to save, retrieve, and delete values.
Example usage
val dataStoreProvider = DataStoreProvider(
fileName = "my_datastore",
context = ...,
)
enum class MyStoreKey: StoreKey {
USER_NAME,
}
dataStoreProvider.putString(MyStoreKey.USER_NAME, "John Doe")
val name: String? = dataStoreProvider.getString(MyStoreKey.USER_NAME)A specialized provider that handles data caching, including logic for checking if cached data is still valid or has expired.
Add the dependency to your commonMain:
dependencies {
implementation("ag.sportradar.mobile.epsilon:epsilon-datastore:<version>")
}Each platform requires a specific way to initialize the DataStore. Epsilon wraps this into the DataStoreProvider constructor and presents a unified way of instantiating the DataStore.