Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use windowSizeBytes argument of AndroidSqliteDriver #5523

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.apollographql.apollo3.cache.normalized.sql

import android.content.Context
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import com.apollographql.apollo3.cache.normalized.api.NormalizedCacheFactory
Expand All @@ -19,22 +20,34 @@ actual class SqlNormalizedCacheFactory actual constructor(
/**
* @param [name] Name of the database file, or null for an in-memory database (as per Android framework implementation).
* @param [factory] Factory class to create instances of [SupportSQLiteOpenHelper]
* @param [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.
* @param [useNoBackupDirectory] Sets whether to use a no backup directory or not.
* @param [windowSizeBytes] Size of cursor window in bytes, per [android.database.CursorWindow] (Android 28+ only), or null to use the default.
*/
@JvmOverloads
constructor(
context: Context,
name: String? = "apollo.db",
factory: SupportSQLiteOpenHelper.Factory = FrameworkSQLiteOpenHelperFactory(),
configure: ((SupportSQLiteDatabase) -> Unit)? = null,
useNoBackupDirectory: Boolean = false,
windowSizeBytes: Long? = null,
withDates: Boolean = false,
) : this(
AndroidSqliteDriver(
getSchema(withDates),
context.applicationContext,
name,
factory,
useNoBackupDirectory = useNoBackupDirectory
object : AndroidSqliteDriver.Callback(getSchema(withDates)) {
override fun onConfigure(db: SupportSQLiteDatabase) {
super.onConfigure(db)
configure?.invoke(db)
}
},
useNoBackupDirectory = useNoBackupDirectory,
windowSizeBytes = windowSizeBytes,
),
withDates
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public final class com/apollographql/apollo3/cache/normalized/sql/SqlNormalizedC
public fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;)V
public fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;Lkotlin/jvm/functions/Function1;)V
public fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;Lkotlin/jvm/functions/Function1;Z)V
public synthetic fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;Lkotlin/jvm/functions/Function1;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;Lkotlin/jvm/functions/Function1;ZLjava/lang/Long;)V
public synthetic fun <init> (Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;Lkotlin/jvm/functions/Function1;ZLjava/lang/Long;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;)V
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun create ()Lcom/apollographql/apollo3/cache/normalized/api/NormalizedCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ actual class SqlNormalizedCacheFactory internal constructor(
* @param [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.
* @param [useNoBackupDirectory] Sets whether to use a no backup directory or not.
* @param [windowSizeBytes] Size of cursor window in bytes, per [android.database.CursorWindow] (Android 28+ only), or null to use the default.
*/
@JvmOverloads
constructor(
Expand All @@ -30,6 +31,7 @@ actual class SqlNormalizedCacheFactory internal constructor(
factory: SupportSQLiteOpenHelper.Factory = FrameworkSQLiteOpenHelperFactory(),
configure: ((SupportSQLiteDatabase) -> Unit)? = null,
useNoBackupDirectory: Boolean = false,
windowSizeBytes: Long? = null,
) : this(
AndroidSqliteDriver(
getSchema(),
Expand All @@ -42,7 +44,8 @@ actual class SqlNormalizedCacheFactory internal constructor(
configure?.invoke(db)
}
},
useNoBackupDirectory = useNoBackupDirectory
useNoBackupDirectory = useNoBackupDirectory,
windowSizeBytes = windowSizeBytes,
),
)

Expand Down