本文介绍了离线缓存数据的Firestore定价说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firestore会向我收取对本地缓存的数据的读取查询的费用,这对我来说似乎很奇怪,但是在 Firestore定价文件.如果我强制Firebase进入脱机模式,然后对本地缓存的数据执行读取操作,我是否仍要为检索到的每个单独实体收费?

It seems odd to me that Firestore would charge me for read queries to locally cached data, but I can't find any clarification to the contrary in the Firestore Pricing document. If I force Firebase into offline mode and then perform reads on my locally cached data, am I still charged for each individual entity that I retrieve?

我的应用程序中的第二个脱机用户向单个实体写入了许多小的更新.我希望每次更改都在本地保留(以防它们退出应用程序),但最终只需要最终一致地保存到云中即可.当用户重新连接到Internet并且Firestore刷新了本地更改时,我是否将为该实体收取单个写入请求,或者我在离线状态下进行的每个update调用都向我收取费用?

Second, offline users in my app write many small updates to a single entity. I want the changes to persist locally each time (in case they quit the app), but I only need eventually consistent saves to the cloud. When a user reconnects to the internet and Firestore flushes the local changes, will I be charged a single write request for the entity or one per update call that I made while offline?

Firestore可能很适合我的用例,但是如果离线读写的收费与在线收费相同,那将是负担不起的选择.

Firestore could potentially fit my use case very well, but if offline reads and writes are charged at the same rate as online ones it would not be an affordable option.

推荐答案

作为官方文档说,

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

So, every client that is using a Firestore database and sets PersistenceEnabled to true, maintains it's own internal (local) version of the database. When data is inserted/updated, it is first written to this local version of the database. As a result, all writes to the database are added to a queue. This means that all the operations that where stored there will be commited on Firebase servers once you are back online. This also means that those operations will be seen as independent operations and not as a whole.

但是请记住,不要将Firestore用作仅脱机数据库.它实际上是作为在线数据库设计的,可以在断开连接的短到中期内工作.脱机时,它将保持写操作队列.随着此队列的增加,本地操作和应用启动将变慢.没什么大不了的,但是随着时间的流逝,这些可能会累加起来.

But remeber, don't use Firestore as an offline-only database. It is really designed as an online database that came work for short to intermediate periods of being disconnected. While offline it will keep queue of write operations. As this queue grows, local operations and app startup will slow down. Nothing major, but over time these may add up.

如果Google Cloud Firestore定价模型不太适合您的用例,请使用Firebase Realtime Database.也如来自Firebase的帖子所述官方博客,您仍然想使用实时数据库的原因之一是:

If Google Cloud Firestore priceing model does not fit your use case very well then use Firebase Realtime Database. As mentioned also in this post from the Firebase offical blog, one the reasons you still might want to use the Realtime Database is:

由您决定选择哪个选项.

So it's up to you which option you choose.

这篇关于离线缓存数据的Firestore定价说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:41
查看更多