Firestore offline data: Merging writes, maximum time of offline persistence

前端 未结 2 1325
無奈伤痛
無奈伤痛 2020-12-15 05:36

https://firebase.google.com/docs/firestore/manage-data/enable-offline

How does Firestore work with offline data?

  1. How are writes merged by many clien

相关标签:
2条回答
  • 2020-12-15 06:02

    I guess the documentation has most of your answers. link

    1. Writes are managed based on time stamps.
    2. As you specified, you are interested in web Firebase client. In that case I guess you may not have access to offline data after browser restarts. If that is not the case, Firebase should be able to manage the writes. I didn't find any specific time limit. However, documentation says

    Firebase applications work even if your app temporarily loses its network connection. In addition, Firebase provides tools for persisting data locally, managing presence, and handling latency.

    that means the data persistence is certainly for a limited time period.

    1. Yes, if there are too many operations, system will have greater load syncing all the writes to the cloud.

    Hope this helps. Please also refer to this link.

    0 讨论(0)
  • 2020-12-15 06:05

    How are writes merged by many clients editing the same data offline, that then come online at the same time?

    The write operations that will take place on Firebase servers, will be in the order in which that series of operations happened. The last operation (the most recent one) will be the one that will be available in the database by the time the synchronization occurs.

    How long is offline data persisted? If my user uses my app for 5 years offline, then comes back online, will this be an issue?

    The problem is not about how long is about how many operations do you make while the device is offline. While offline, Firestore will keep in queue all the write operations. As this queue grows, local operations and app startup will slow down. Nothing major, but over time these may add up. The major problem in this case is that the end result of this will be that the data on the server stays unmodified. Then what is the purpose of a realtime database? Firestore is really designed as an online database that came work for short to intermediate periods of being disconnected, not to stay offline for 5 years. Beside that, in 5 years it might be a problem of compatibility and not of the number of writes.

    Do offline changes persist after device restarts?

    The offline persistence is also called disk persistence. This type of persistence is enabled by default in Cloud Firestore and it means that recently listened data (as well as any pending writes from the app to the database) are persisted to disk. The data in this cache survives app restarts and device reboots.

    Does query performance of offline data degrade as the data set gets larger?

    Yes it does, like explained above.

    Do all the language clients implement the above in the same manner?

    No. For iOS and Android, the offline feature works fine while for web, this feature is still experimental.

    0 讨论(0)
提交回复
热议问题