How reliable is Firestore as an offline persistence mechanism?

前端 未结 2 1705
后悔当初
后悔当初 2020-12-02 20:41

I am currently using Firebase Firestore as a primary backend that retrieves data from a variety of sources. I also use Android\'s Room for my mobile backend. When the phone

2条回答
  •  不思量自难忘°
    2020-12-02 21:32

    On Android (as of this writing) Firestore uses SQLite as a persistence mechanism. So for intermittent periods of offline activity you should have no problems with performance or durability.

    However if you are going to be offline for days or weeks (as you said) there are some things you should be aware of:

    Performance

    Because Cloud Firestore is meant to be used mostly online, pending writes that have not yet been synced to the server are held in a queue. If you do many pending writes without going online to resolve them, that queue will grow and it will slow down your overall read/write performance. Most of Cloud Firestore's performance guarantees come from indexing and replication on the backend, but most of those optimizations don't exist when you're operating offline-only.

    Conflicts

    Firestore's basic conflict resolution model is "last write wins". So if you have many offline clients writing to the same document, only the last one to come online will actually "win" and persist their change.

    Features

    Most of Firestore's features work offline with one major exception: transactions. Transactions can only execute when you are online. So if your app uses transactions it will not work properly offline without some special handling.

提交回复
热议问题