SqliteStorage

open class SqliteStorage(connection: ERROR CLASS: Symbol not found for SQLiteConnection, clock: ERROR CLASS: Symbol not found for Clock = Clock.System, coroutineContext: ERROR CLASS: Symbol not found for CoroutineContext = Dispatchers.IO, keySize: Int = 9) : BaseStorage

Storage implementation based on Kotlin Multiplatform androidx.sqlite.SQLiteConnection API.

One limitation of androidx.sqlite.SQLiteConnection APIs is that there is no way to get result from UPDATE and DELETE SQL statements. This can be worked around either using SQLite-specific RETURNING clause (without breaking atomicity) or by additional SELECT statements (this does break atomicity).

Note: currently we use this implementation only for iOS as there are multiple problems using this code on Android:

  • required androidx.sqlite library version (2.5.0-alpha12) conflicts with some other commonly used Android libraries.

  • implementation supplied by AndroidSQLiteDriver lacks support for SQLite-specific RETURNING clause and thus it is not possible to guarantee truly atomic operations (most notably insertions with unique keys and correct return value from deletions).

Inheritors

Constructors

Link copied to clipboard
constructor(connection: ERROR CLASS: Symbol not found for SQLiteConnection, clock: ERROR CLASS: Symbol not found for Clock = Clock.System, coroutineContext: ERROR CLASS: Symbol not found for CoroutineContext = Dispatchers.IO, keySize: Int = 9)

Properties

Link copied to clipboard
val clock: kotlin/time/Clock

Functions

Link copied to clipboard
open suspend override fun getTable(spec: StorageTableSpec): StorageTable

Get the table with specific name and features.

Link copied to clipboard
open suspend override fun purgeExpired()

Reclaim the storage occupied by expired entries across all tables in this Storage object (even if these tables were never accessed using getTable in this session).