-
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?
Conversation
✅ Docs Preview ReadyNo new or changed pages found. |
/** | ||
* Closes resources associated with the cache if any. | ||
* This function must not call `nextCache.close()`, this is done by the caller. | ||
*/ | ||
override fun close() { | ||
} |
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.
I went with SqlNormalizedCache.close()
and not SqlNormalizedCacheFactory.close()
because I think it makes more sense? Ultimately, SqlNormalizedCacheFactory
may be turned into a plain Kotlin function like we have () -> OkHttpClient
for lazy initialization, we could have () -> NormalizedCache
, this is the same pattern.
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.
Yes, that's more intuitive than a closeable factory 👍
Now if a driver is passed, or a factory is re-used, apolloStore.close()
must be called with caution. Should we call that out, maybe in the KDoc of the SqlNormalizedCacheFactory(driver: SqlDriver)
constructor?
* Closes resources associated with the cache if any. | ||
* This function must not call `nextCache.close()`, this is done by the caller. |
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.
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.
👍
Related: #3564 |
See #6281
See apollographql/apollo-kotlin-normalized-cache-incubating#67
See apollographql/apollo-kotlin-normalized-cache-incubating#66