Comments (11)
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.
Hi @jamesreggio, I wanted to check if this is still on the roadmap? Thanks.
from apollo-cache-persist.
Hi @jamesreggio,
I was hoping to find out if there were any updates regarding TTL/expiration times?
from apollo-cache-persist.
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.
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.
@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.
@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.
You're welcome! Not sure about the next major version, but not anytime soon.
from apollo-cache-persist.
@wtrocki Happy to contribute. Are there any specific guidelines for this repo?
from apollo-cache-persist.
@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.
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)
- Prevent user to close browser tab when there is pending writes HOT 4
- Feature Request: Associated time that given fields/entire cache was last updated HOT 1
- PersistMapper/PersistLink doesn't support nested cache item reference
- [Discussion] Allow for individual cache items to be saved instead of current single-key implementation HOT 1
- Don't persist @client fields? HOT 3
- AsyncStorage or window.Local storage should I use on Web? live LocalStore HOT 2
- Lazy loading cache HOT 1
- "this" has been rewritten to "undefined" HOT 1
- Why was the persistLink and persistenceMapper example removed? HOT 2
- [Request] - Please update code for MMKVStorage instance creation as per their new implementation HOT 1
- Duplication of entire / partial cache object in MMKV storage HOT 7
- [question] What's the recommended way to handle render exceptions caused by stale persisted cached data? HOT 1
- [Question] Collaborative / multiplayer caching / syncing engine? HOT 2
- Calling client.clearStore() does not reset the persistence layer HOT 4
- this.fire is not used in this case
- useLazyQuery not returning the cache value when I request on click or with delay. HOT 1
- Help for adding support apollo client next js HOT 2
- The UI is not updated when mutating the cache with writeFragment
- Is it possible not to persist data to storage if it's undefined ? HOT 4
- Garbage collection isn't working with cache persistance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-cache-persist.