本文介绍了Firestore离线数据:合并写入,最大离线持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Firestore如何处理离线数据?

How does Firestore work with offline data?

  1. 许多脱机编辑同一数据的客户端如何合并写入,然后同时联机?

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

离线数据可以保留多长时间?如果我的用户离线使用我的应用程序已有5年,然后又恢复在线状态,这会成为问题吗?设备重启后,离线更改是否仍然存在?

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? Do offline changes persist after device restarts?

脱机数据的查询性能是否会随着数据集的增大而降低?

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

我对Web Firestore客户端特别感兴趣.

Im specifically interested in the web Firestore client.

所有语言客户端是否都以相同的方式实现上述目的?

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

谢谢.

推荐答案

将在Firebase服务器上进行的写操作将按照该系列操作发生的顺序进行.最后一个操作(最新操作)将是在同步发生时在数据库中可用的操作.

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.

问题不在于设备离线时进行多少次操作.离线时,Firestore将使所有写操作排入队列.随着此队列的增加,本地操作和应用启动将变慢.没什么大不了的,但是随着时间的流逝,这些可能会加起来.在这种情况下,主要问题是最终结果将是服务器上的数据保持不变.那么,实时数据库的目的是什么? Firestore实际上是作为在线数据库设计的,可以在断开连接的短到中期内工作,而不会在离线状态下保持5年.除此之外,在5年内这可能是兼容性问题,而不是写入次数问题.

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.

脱机持久性也称为磁盘持久性.默认情况下,Cloud Firestore中启用了这种类型的持久性,这意味着最近侦听的数据(以及从应用程序到数据库的所有挂起的写操作)都将持久化到磁盘.此缓存中的数据在应用程序重启和设备重启后仍然有效.

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.

是的,就像上面解释的那样.

Yes it does, like explained above.

不.对于iOS和Android,离线功能可以正常工作,而对于网络,此功能仍处于试验阶段.

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

这篇关于Firestore离线数据:合并写入,最大离线持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 00:55