GithubHelp home page GithubHelp logo

Comments (11)

wtrocki avatar wtrocki commented on May 5, 2024 5

Cache expiration is actually one of the main features of the Apollo Client 3.0.
The community also providing the number of workarounds to achieve that for the moment. Doing that in cache persist is not an option as the removed item will be written again from InMemory store. We are happy to accept any suggestions but in some cases like this, we will be constrained by the modular architecture of the Apollo ecosystem.

See: apollographql/apollo-feature-requests#4 (comment)

from apollo-cache-persist.

visheshd avatar visheshd commented on May 5, 2024 2

Hi @jamesreggio, I wanted to check if this is still on the roadmap? Thanks.

from apollo-cache-persist.

hwhh avatar hwhh commented on May 5, 2024 2

Hi @jamesreggio,

I was hoping to find out if there were any updates regarding TTL/expiration times?

from apollo-cache-persist.

hwhh avatar hwhh commented on May 5, 2024 2

Hi @wtrocki,

Thanks for getting back to me, yes this question in relation to Apollo 3.0; I opened an issue here apollographql/apollo-client#6484 (comment) but saw this issue too. I am not sure if it is possible, but (at least when using react-native) when items are persisted in the background, would it also be possible to remove expired items in the background as well?

from apollo-cache-persist.

jamesreggio avatar jamesreggio commented on May 5, 2024 1

Hi @padupuy

Unfortunately, that's not possible today. Supporting per-key metadata (including a TTL/expiration time) is on the roadmap for the next major release, but it's unlikely to become available prior to then, due to the significant API changes it would require.

#2 has a broader conversation around cache filtering/expiration, and I expect we'll continue the conversation over there once it's time to implement this feature.

Until then, I'd suggest you stick with fetchPolicy: 'cache-and-network'. apollo-link-dedup can help to mitigate the number of HTTP requests made to fulfill the 'network' half of that perhaps-too-aggressive fetch policy.

from apollo-cache-persist.

wtrocki avatar wtrocki commented on May 5, 2024 1

@visheshd Roadmap is available here #94 . Feel free to suggest new items.
This package is maintained by the community and we looking for contributors interested in improving this package.

from apollo-cache-persist.

padupuy avatar padupuy commented on May 5, 2024

@jamesreggio thank you for your kind answer and your suggestion I already use apollo-link-batch-http.
Any idea when next major version will be release ?

from apollo-cache-persist.

jamesreggio avatar jamesreggio commented on May 5, 2024

You're welcome! Not sure about the next major version, but not anytime soon.

from apollo-cache-persist.

visheshd avatar visheshd commented on May 5, 2024

@wtrocki Happy to contribute. Are there any specific guidelines for this repo?

from apollo-cache-persist.

wtrocki avatar wtrocki commented on May 5, 2024

@hwhh is this question in relation to Apollo 3.0. Generally TTL are handled on cache level.
Persist is just saving what cache has.

from apollo-cache-persist.

disarticulate avatar disarticulate commented on May 5, 2024

quick hotfix for me to invalidate cache regularly:

const persist = await persistCache({
    cache,
    debounce: 100,
    storage: new LocalForageWrapper(graphqlStore),
  })
  const TTL = localStorage.getItem('graphql-persist-TTL')
  const TTLfuture = new Date().valueOf() + (60 * 1000 * 60) // 1 hour
  if (!TTL) {
    localStorage.setItem('graphql-persist-TTL', TTLfuture)
  } else if (parseInt(TTL) < new Date().valueOf()) {
    localStorage.setItem('graphql-persist-TTL', TTLfuture)
    persist.purge()
  }

ok, this doesn't work because apparently nothing is returned? Seems odd to not return the object the cache is based on. gonna need to monkey patch it.

from apollo-cache-persist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.