-
Notifications
You must be signed in to change notification settings - Fork 7
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
Provide a TTL (time to live) cache mechanism #361
Comments
Could you explain this a bit more? I might be misunderstanding, but I read this as we want to introduce a new I'd push back against that a little bit as I think a TTL config would likely be configuration on the cache, or something that would live alongside the existing fetch policies on queries that write to the cache. |
@jerelmiller Understood, this was one idea we can consider what the best approach could be given some use cases that are coming up. I'll share some more details with you directly. |
fetchPolicy
I have implemented a fetch policy with expiration, if that's of any help.
However, I'm finding it hard to make this implementation work with |
To help provide better support for Apollo Client caching strategy that uses TTLs. We are considering offering a
fetchPolicy
that would allow a user to set a TTL value or some other cache control mechanism that can use a TTL value for caching.As a workaround we've recommended to create a read/merge function for our type that enriches the object with a timestamp on merge and then determine the time elapsed on read. If it is greater than the TTL you'd then schedule cache eviction and refetch the data.
This was a clever idea however some users are reporting issues with this approach:
After the first two read calls and merge call neither function is called again. Even when the page is unmounted and remounted the read function would no longer be called after the first couple times. This happens regardless of time elapsed and is reproducible by including a log statement and unconditionally returning the object from the read function.
Relates to: apollographql/apollo-kotlin#3566 (comment)
The text was updated successfully, but these errors were encountered: