Skip to content
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 Expiration / TTL to InMemoryCache #336

Open
Sumu-Ning opened this issue Jul 19, 2022 · 5 comments
Open

Add Expiration / TTL to InMemoryCache #336

Sumu-Ning opened this issue Jul 19, 2022 · 5 comments
Labels
📕 cache Feature requests related to the cache

Comments

@Sumu-Ning
Copy link

Sumu-Ning commented Jul 19, 2022

We are using ApolloClient + InMemoryCache to do some GraphQL queries. However, our backend data is not immutable, and therefore, we might need to get the fresh data every some time. It looks like the current InMemoryCache does not have a way to set the TTL to cached data, and the data will stay there for a long time, if not kicked out by size limit.

I would like to suggest to add a feature in InMemoryCache to limit the Time-to-live in InMemoryCache, which can be implemented in either an eager or lazy way.

Product Questions to consider

  1. TTL means in a normalized cache each field can potentially have different TTL values. would the approach follow a pattern such as:
  • TTL per-field
  • TTL per-query
  • TTL per-object
  • TTL per something else?
  1. Is the TTL client or server controlled?

  2. Would we apply this to all 3 clients?

  • iOS
  • Kotlin
  • Web Client?
@jpvajda jpvajda added the project-apollo-client (legacy) LEGACY TAG DO NOT USE label Jul 19, 2022
@jpvajda
Copy link
Contributor

jpvajda commented Jul 20, 2022

@Sumu-Ning Thanks for reporting this, we'll consider it and keep this FR open for others in the community to share their thoughts. I also added some product considerations we'd be making in implementing something such as this.

@jerelmiller jerelmiller added the 📕 cache Feature requests related to the cache label Apr 6, 2023
@jerelmiller jerelmiller removed the project-apollo-client (legacy) LEGACY TAG DO NOT USE label Jan 22, 2024
@torressam333
Copy link

Has there been any progress on adding TTL configuration for apollo client cache? It would be nice to have this fine grained control over cache expiration. Thanks!

@jerelmiller
Copy link
Member

@torressam333 no updates to share at the moment 🙂. We are aware of the growing popularity of this request but we haven't yet prioritized it on our roadmap. We'll update this request when we know more.

@torressam333
Copy link

torressam333 commented Mar 11, 2024

@jerelmiller Sounds good.

Is the recommended approach for custom cache management to use eviction/gc for the time being?

https://www.apollographql.com/docs/react/caching/garbage-collection

Thanks!

@jerelmiller
Copy link
Member

@torressam333 yep that should work for you 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📕 cache Feature requests related to the cache
Projects
None yet
Development

No branches or pull requests

4 participants