-
Notifications
You must be signed in to change notification settings - Fork 740
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
Allow to clear the cache synchronously #1186
Allow to clear the cache synchronously #1186
Conversation
30dcd33
to
05db51a
Compare
@gsabran This is probably a couple things:
I'm actually kind of surprised to see we're not firing this off to the background for the SQLite implementation, that seems a bit like a better idea, but maybe it's doing that under the hood? I haven't dug deep enough to see quite yet. |
Yes I was surprised as well. I was first synchronously waiting on this call to complete, before realizing that there was no async work done. |
|
Yeah, I'm just confused why that is as I updated this class. |
Looks like you'll need to try again 🙃 |
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.
Looks good!
Thanks! |
@@ -32,9 +32,7 @@ public final class InMemoryNormalizedCache: NormalizedCache { | |||
|
|||
public func clear(callbackQueue: DispatchQueue?, |
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.
IMO we should make handler non optional here, otherwise its easy to miss that its asynchronous operation
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.
Eh, I can still see a case for people wanting it to fire off in a non-blocking way but not wanting to pass in a handler, I don't think it's worth it.
I don't really understand why the existing methods have completion blocks while all the work is done synchronously on the caller thread. This gives the impression that the work is being offloaded to another queue which is not the case. I guess the protocol should not be concerned with the existing implementations. That said I've not replaced the existing methods for backward compatibility.
I had a need for synchronous cache clearance to ensure that everything is done right when the user logs out.