PersistentCacheSettings constructor
PersistentCacheSettings({
- int sizeBytes = Settings.defaultCacheSizeBytes,
- bool indexAutoCreation = false,
- IndexBackfillSettings? indexBackfill,
- bool mergeUnsentWrites = false,
sizeBytes is an approximate cache size threshold: if the cache grows
beyond it, Firestore starts removing data that has not been recently used.
Use Settings.cacheSizeUnlimited to disable the collection. The
minimum is 1 MB, an ArgumentError is thrown otherwise.
indexAutoCreation and indexBackfill configure the persistent cache
indexes; the defaults are the behaviour of the official SDKs.
mergeUnsentWrites is an opt-in extension that differs from the official SDKs, off by default, see
mergeUnsentWrites.
Implementation
PersistentCacheSettings({
this.sizeBytes = Settings.defaultCacheSizeBytes,
this.indexAutoCreation = false,
IndexBackfillSettings? indexBackfill,
this.mergeUnsentWrites = false,
}) : indexBackfill = indexBackfill ?? IndexBackfillSettings() {
if (sizeBytes != Settings.cacheSizeUnlimited &&
sizeBytes < Settings.minimumCacheBytes) {
throw ArgumentError(
'Cache size must be set to at least ${Settings.minimumCacheBytes} bytes',
);
}
}