SqlitePropertyStore
SQLite-backed property store for persisting configuration properties.
Use this store when you need durable property storage with SQLite. Properties are serialized as JSON, enabling storage of any property type including custom implementations.
Optimistic Locking
Operations that update existing properties (such as updateProperty) use optimistic locking to prevent lost updates when multiple clients modify the same property concurrently. If a concurrent modification is detected, the operation retries automatically (up to 10 times) before failing.
Note: createOrUpdate performs a plain upsert with last-write-wins semantics and does not use optimistic locking.
Setup
You must create the database schema before using the store:
// JVM with in-memory database
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
SqliteDatabase.Schema.create(driver).await()
val store = SqlitePropertyStore(driver)
// Android
val driver = AndroidSqliteDriver(SqliteDatabase.Schema, context, "ff4k.db")
val store = SqlitePropertyStore(driver)
// iOS
val driver = NativeSqliteDriver(SqliteDatabase.Schema, "ff4k.db")
val store = SqlitePropertyStore(driver)Custom Property Types
To store custom property implementations, provide a serializers module:
val customModule = SerializersModule {
polymorphic(Property::class) {
subclass(MyCustomProperty::class, MyCustomProperty.serializer())
}
}
val store = SqlitePropertyStore(driver, customModule)Parameters
The SQLDelight driver connected to your SQLite database.
Serializers for custom property types you want to store.
Constructors
Functions
Stores a property, creating it if new or updating it if it exists.