Closed gregfenton closed 3 years ago
That's the classic computer science problem: cache invalidation is hard.
This problem doesn't seem related to this library. Instead, it seems related to Firestore's persistence in general (or so I would think).
Maybe check if firestore lets you clear the persistence cache?
If you look in the source code here, all this lib does is let us access SQLite.
According to this stack-overflow post, there is a clearPersistence()
API. Looks like this is the documentation for the API.
Thanks for the quick response!
(And in computer science the only thing harder than cache invalidation is: naming things)
FWIW, I recommend using some sort of unique key to determine if your schema has changed.
In my app, I often associate this with the expo publish ID. If the ID changed, wipe out the persistence cache. Otherwise, persist. There are probably better strategies but that's what I rely on.
In my app, I often associate this with the expo publish ID. If the ID changed, wipe out the persistence cache. Otherwise, persist. There are probably better strategies but that's what I rely on.
Got a code snippet you could share?
I'm not clear on how you are getting the publish ID and comparing to what the persistence has. Are you updating the persistence value directly (i.e. shoving a value into SQLite) that you compare on each start of your app, then clearing the cache if there is a mismatch and putting the current publish ID into the SQLite?
I'm refactoring my entire Firestore schema. I've loaded the FS emulator with the old schema, run my expo app in the iOS Simulator.
Then I reset the emulator with all fresh data and re-start the iOS app. I am getting both old and new data (old data is NOT in the Firestore emulator).
When I disable persistence and restart the iOS app, I am only seeing the new data.
Thoughts on how/why those old docs are still there? Is there a recommended way to "reset the persistence" when using
expo-firestore-offline-persistence
?(BTW: A million THANKS for your contribution to the community!!)