apollographql / apollo-cache-persist

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

AsyncStorageWrapper cache data missing / disappearing #533

Closed PeterKucera closed 1 month ago

PeterKucera commented 1 month ago

Hey folks

I'll just leave this as a note here - I was running into issue where Apollo Cache was being deleted, and I couldn't figure out what's causing this.

Looks like root cause for this issue was that when you call a persistCache() method, initial cache size is set to 1MB, and if your cache exceeds this amount, cache will be overridden / purged.

Solution is to set persistCache() maxSize arg to a large number (or ideally to false), so there won't be any limit on the cache size, and therefore it won't get purged when it gets full.

https://github.com/apollographql/apollo-cache-persist/blob/master/docs/advanced-usage.md

image

diego-betto commented 1 month ago

Thank you @PeterKucera, you saved my day :)