-
Notifications
You must be signed in to change notification settings - Fork 64
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
How to ensure findOneById bypasses the cache and gets the data from the database? #38
Comments
Let's say you have two different gql resolvers. Resolver A comes under very heavy load and can return slightly stale values. Resolver B is hit rarely, but must return the latest value. Resolver B still wants to take advantage of the DataLoader semantics which guarantee that at most one db-fetch is issued for a particular ID, but this one db-fetch must come from mongodb, not Redis. Meanwhile, Resolver A is constantly causing Resolver B to get cache hits from Redis, because Possible solution A: This package could make the dataloader instance available to subclasses. solution A seems preferable. Would you accept a PR for that? |
Makes sense! Pro/cons of A vs adding an option like |
Thanks for the fast response @lorensr ! I think the API you proposed is reasonable, but there is one drawback. Does I think the drawback is that some future person like me might open another issue asking for this. If you let the subclass access the dataloader, this provides the most flexibility. Thoughts? |
Sounds good, would appreciate PR for A, thanks
…On Fri, Oct 16, 2020 at 12:15 AM Doron Roberts-Kedes < ***@***.***> wrote:
Thanks for the fast response @lorensr <https://github.com/lorensr> !
I think the API you proposed is reasonable, but there is one drawback.
Hypothetically, a subclass could want to do any combination of
bypassCacheOnRead: yes/no, writeToCache: yes/no.
I think the drawback is that some future person like me might open another
issue asking for this. If you let the subclass access the dataloader, this
provides the most flexibility.
Thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5LGBMBQCGBLE4XFIZTCLSK7CF3ANCNFSM4SRNARUQ>
.
|
Cool. I'm living the startup life at the moment, but will try and get to this. |
There doesn't seem to be a way to ensure that
findOneById
gets its value directly from the database. If TTL is unset, then the read will not populate the cache after fetching the document, but it will always try to get the key from the cache regardless of the value of TTL.Is there a particular reason why this behavior is not supported? Sometimes when a use-case isn't supported, it makes me think I'm barking up the wrong tree. However, it seems reasonable to want to ensure that a given query gets the latest value from mongodb, even if a subsequent load was issued with a non-zero TTL.
Thoughts?
The text was updated successfully, but these errors were encountered: