Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Cache "how it works" #92

Closed
piotrblasiak opened this issue Jul 9, 2017 · 3 comments
Closed

Cache "how it works" #92

piotrblasiak opened this issue Jul 9, 2017 · 3 comments

Comments

@piotrblasiak
Copy link

It is quite important to me to know how the cache works in order to be able to stop the client from evicting data when in offline mode. I´m using react-apollo but I assume this will be important for all clients. Is there such a document/guide/thread already that I have missed?

@stubailo
Copy link
Contributor

stubailo commented Jul 9, 2017

Currently no data is evicted, but we're working on some refactors to make the implementation more flexible and swappable.

For example, you'll be able to replace the redux cache with a different backend, etc.

Do you have any particular questions I can answer? We have a bit of info about how stuff works and there is also the devtools, but I'm not sure exactly what you're asking about.

@piotrblasiak
Copy link
Author

piotrblasiak commented Jul 9, 2017

Oh, so once an entity is loaded it stays in the cache forever? My use case, which I think should be pretty common is that I load something like this:

@graphql(gql`{
query($projectId: ID!) {
  project(id: $projectId) {
    childEntities {...}
  }
}`

And I want the data that is referenced by that component to be available to it for as long as it needs it. But once the $projectId changes the previously loaded data may not be needed again for quite some time if ever. I would expect some garbage collection to happen, but you´re saying there is nothing like that currently? If so, how do you stop an application using apollo from using up a ton of memory in the end?

@stubailo
Copy link
Contributor

If so, how do you stop an application using apollo from using up a ton of memory in the end?

You can call resetStore periodically to avoid this, but we're working on cache improvements that will make this no longer the case. First step is decoupling the store from the core so that it's easy to plug in new cache implementations with different features, and offline is the primary motivating use case for this new approach.

See here: apollographql/apollo-client#1432 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants