SqlNormalizedCacheFactory

fun SqlNormalizedCacheFactory(context: Context, name: String? = "apollo.db", factory: SupportSQLiteOpenHelper.Factory = FrameworkSQLiteOpenHelperFactory(), configure: (SupportSQLiteDatabase) -> Unit? = null, useNoBackupDirectory: Boolean = false, windowSizeBytes: Long? = 4 * 1024 * 1024): NormalizedCacheFactory

Parameters

name

Name of the database file in the cache directory, or an absolute path to a file, or null for an in-memory database (as per Android framework implementation).

factory

Factory class to create instances of SupportSQLiteOpenHelper

configure

Optional callback, called when the database connection is being configured, to enable features such as write-ahead logging or foreign key support. It should not modify the database except to configure it.

useNoBackupDirectory

Sets whether to use a no backup directory or not.

windowSizeBytes

Size of cursor window in bytes, per android.database.CursorWindow (Android 28+ only). Defaults to 4 MiB - pass null to use the system default (2 MiB as of Android 28).




expect fun SqlNormalizedCacheFactory(name: String? = "apollo.db"): NormalizedCacheFactory

Creates a new NormalizedCacheFactory that uses a persistent cache based on Sqlite

Parameters

name

The name of the database or null for an in-memory database When not in memory, the database will be stored in a platform specific folder

  • on Android it will use Context.getCacheDir. It can also be an absolute path to a file.

  • on MacOS, it will use "Application Support/databases/name"

  • on the JVM, it will use "System.getProperty("user.home")/.apollo"

  • on JS/Wasm, this argument is unused

Default: "apollo.db"

Returns a SqlNormalizedCacheFactory configured with the default driver which works with SQL.js. For this to work you must have these dependencies in your project:

implementation(npm("@cashapp/sqldelight-sqljs-worker", "2.1.0"))
implementation(npm("sql.js", "1.8.0"))

See the SQLDelight documentation.

Parameters

url

Database connection URL in the form of jdbc:sqlite:path where path is either blank (creating an in-memory database) or a path to a file.

properties