apollographql / apollo-cache-persist

🎏 Simple persistence for all Apollo Cache implementations
MIT License
1.39k stars 118 forks source link

Garbage collection isn't working with cache persistance #514

Closed asvishnyakov closed 7 months ago

asvishnyakov commented 8 months ago
  1. Load component 1 which call query 1 which put object 1 to cache
  2. Switch to component 2 which call query 2 (now it's active) which put object 2 to cache.
  3. Call cache.gc(). Because query 1 is not longer active, object 1 will be removed from cache and only object 2 left.

But because apollo-cache-persist doesn't call persist on garbage collection, object 1 will be left on persistence layer and restored back on app reload. It will never be removed from that until we manually call cache.evict. It doesn't allow to use automatic garbage collection with apollo-cache-persist and require manual cache management for effectiveness.

wodCZ commented 7 months ago

Released in 0.15.0.

Please let me know if the version is acting weird. There were multiple major releases of the bundling and other dev tools since the last release and even though I tested in my projects, I'm not sure all setups work the same they did with 0.14.

asvishnyakov commented 7 months ago

@wodCZ Thank you! But GitHub Release wasn't created, if it should.