How Does Firestore Cache Management Work and What Causes Data Loss in Offline Mode? #12277
Replies: 1 comment 6 replies
-
Hi @vinhhoangbepos. The cache size limit should not be causing any data loss. Data is only evicted from the cache if it is no longer needed. For example, documents that are added while offline and documents from a query that has an active snapshot listener are not candidate for eviction from the cache. In contrast, the result of a query that was run last week are candidate for eviction from the cache. So even if the cache size limit is exceeded the data will only be evicted once it is no longer needed. Could you describe the "data loss" that you are observing in more detail? Unfortunately, the term "data loss" describes a large class of problems and specifics could be helpful in this case. For example, are you observing that you create documents and they "disappear"? You could also try enabling Firestore debug logs by calling |
Beta Was this translation helpful? Give feedback.
-
Hello @dconeybe and Firebase team,
We've recently encountered an issue with data loss in our app, specifically when operating in offline mode. To provide more context, here is our current Firestore cache configuration:
FIRFirestoreSettings *settings = [[FIRFirestoreSettings alloc] init];
settings.cacheSizeBytes = 50 * 1024 * 1024; // 50 MB
settings.persistenceEnabled = YES;
[FIRFirestore firestore].settings = settings;
My question is about the handling of newly added documents in Firestore while in offline mode, especially concerning the cache size limit. Specifically:
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions