KeyValueCacheSettings class final
Configures a persistent cache in a key-value store that the app brings (CacheStore): an ordered store of byte
keys and byte values, such as a file, an embedded database or a platform store.
The stored format is versioned: a newer SDK migrates a store written by an older one, and an older SDK refuses a store written by a newer one (see docs/keyvalue_cache_format.md). Limits: one instance and one client per store (no primary lease, no coordination of tabs or processes), and the writes of each transaction are held in memory until it commits. See docs/guides/custom_cache_store.md.
The SDK lays the whole cache out in the store (documents, pending writes, targets, bundles, the garbage collector's sequence numbers) in a format of its own, with a schema version. The data and the pending writes survive a restart of the program as long as the store keeps them. The store is opened when the instance starts and closed when it is terminated; it holds the cache of one instance (one database) at a time.
Garbage collection runs as with PersistentCacheSettings once the documents take more than sizeBytes, and the
persistent cache indexes work as there (indexAutoCreation, indexBackfill, PersistentCacheIndexManager). Only
one client uses the cache: it is always the primary client.
The cache is in its own library, so that apps that do not use it do not carry its code: create the settings with
keyValueCacheSettings() of package:cloud_firestore_dart/cache_store.dart.
import 'package:cloud_firestore_dart/cache_store.dart';
final FirebaseFirestore firestore = FirebaseFirestore.instanceFor(
app: app,
settings: Settings(cacheSettings: keyValueCacheSettings(store: myStore)),
);
NOT IN THE OFFICIAL SDKS.
- Inheritance
-
- Object
- LocalCacheSettings
- KeyValueCacheSettings
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- indexAutoCreation → bool
-
See PersistentCacheSettings.indexAutoCreation.
final
- indexBackfill → IndexBackfillSettings
-
See PersistentCacheSettings.indexBackfill.
final
- mergeUnsentWrites → bool
-
See PersistentCacheSettings.mergeUnsentWrites.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sizeBytes → int
-
The cache size threshold, in bytes: the size of the cached documents as the SDK writes them to the store.
final
- store → CacheStore
-
The store that holds the cache.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override