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

问题描述

https://firebase.google.com/docs/firestore/管理数据/启用离线

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.

离线数据会持续多久?如果我的用户离线使用我的应用 5 年,然后重新上线,这会成为问题吗?

问题不在于设备离线时进行了多少操作.离线时,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-22 22:32