gpt4 book ai didi

firebase - 离线缓存数据的 Firestore 定价说明

转载 作者:行者123 更新时间:2023-12-02 21:59:07 25 4
gpt4 key购买 nike

对我来说,Firestore 会向我收取本地缓存数据的读取查询费用,这似乎很奇怪,但我在 Firestore Pricing document 中找不到任何相反的说明。 。如果我强制 Firebase 进入离线模式,然后对本地缓存的数据执行读取,我是否仍需为检索的每个单独实体付费?

其次,我的应用中的离线用户向单个实体写入许多小更新。我希望每次更改都在本地保存(以防他们退出应用程序),但我只需要最终一致的保存到云中。当用户重新连接到互联网并且 Firestore 刷新本地更改时,我是否需要为该实体的单个写入请求付费,还是为我在离线状态下进行的每个更新调用付费?

Firestore 可能非常适合我的用例,但如果离线读取和写入的收费与在线读取和写入的费用相同,那么这将不是一个负担得起的选择。

最佳答案

作为offical documentation说,

Cloud Firestore supports offline data persistence. This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline. You can write, read, listen to, and query the cached data. When the device comes back online, Cloud Firestore synchronizes any local changes made by your app to the data stored remotely in Cloud Firestore.

因此,每个使用 Firestore 数据库并将 PersistenceEnabled 设置为 true 的客户端都会维护自己的数据库内部(本地)版本。当插入/更新数据时,它首先被写入数据库的本地版本。因此,对数据库的所有写入都会添加到队列中。这意味着一旦您重新上线,存储在那里的所有操作都将提交到 Firebase 服务器上。这也意味着这些操作将被视为独立操作而不是整体。

但请记住,请勿将 Firestore 用作仅供离线使用的数据库。它实际上被设计为一个在线数据库,可以在短期到中期的断开连接期间工作。离线时,它将保留写操作队列。随着此队列的增长,本地操作和应用程序启动速度将会减慢。没什么大不了的,但随着时间的推移,这些可能会增加。

如果 Google Cloud Firestore 定价模型不太适合您的使用场景,请使用 Firebase 实时数据库。正如本文post中也提到的那样根据 Firebase 官方博客,您可能仍想使用实时数据库的原因之一是:

As we noted above, Cloud Firestore's pricing model means that applications that perform very large numbers of small reads and writes per second per client could be significantly more expensive than a similarly performing app in the Realtime Database.

因此,选择哪个选项取决于您。

关于firebase - 离线缓存数据的 Firestore 定价说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47178737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com