-
Notifications
You must be signed in to change notification settings - Fork 660
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
Add ApolloStore.close()
and NormalizedCache.close()
#6299
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,6 @@ annotation class ApolloDeprecatedSince(val version: Version) { | |
v4_0_0, | ||
v4_0_1, | ||
v4_0_2, | ||
v4_1_1, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.apollographql.apollo.cache.normalized.api | ||
|
||
import okio.Closeable | ||
import kotlin.jvm.JvmStatic | ||
import kotlin.jvm.JvmSuppressWildcards | ||
import kotlin.reflect.KClass | ||
|
@@ -17,7 +18,7 @@ import kotlin.reflect.KClass | |
* | ||
* A [NormalizedCache] can choose to store records in any manner. | ||
*/ | ||
abstract class NormalizedCache : ReadOnlyNormalizedCache { | ||
abstract class NormalizedCache : ReadOnlyNormalizedCache, Closeable { | ||
var nextCache: NormalizedCache? = null | ||
private set | ||
|
||
|
@@ -146,5 +147,12 @@ abstract class NormalizedCache : ReadOnlyNormalizedCache { | |
|
||
private val specialChars = "()^$.*?+{}" | ||
} | ||
|
||
/** | ||
* Closes resources associated with the cache if any. | ||
* This function must not call `nextCache.close()`, this is done by the caller. | ||
*/ | ||
override fun close() { | ||
} | ||
Comment on lines
+151
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's more intuitive than a closeable factory 👍 Now if a driver is passed, or a factory is re-used, |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very easy to forget calling
nextCache.close()
so I went with this but no strong opinion there.