PersistentCacheSettings constructor

PersistentCacheSettings({
  1. int sizeBytes = Settings.defaultCacheSizeBytes,
  2. bool indexAutoCreation = false,
  3. IndexBackfillSettings? indexBackfill,
  4. 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',
    );
  }
}