简体   繁体   English

Firestore 是否不对启用持久性的读取查询中缓存且未更改的文档收费?

[英]Does Firestore not charge for documents that are cached and unchanged in a Read query with persistence enabled?

My assumption was that Firestore would not consider the client cache when evaluating Read usage.我的假设是 Firestore 在评估读取使用情况时不会考虑客户端缓存。 However, when I have persistence enabled in my application, it seems I can run the same queries endlessly and not see any change in my usage metrics.然而,当我在我的应用程序中启用了持久性时,我似乎可以无休止地运行相同的查询并且看不到我的使用指标有任何变化。 I've tested this over and over - when persistence is disabled, I see the usage metrics go up.我已经一遍又一遍地对此进行了测试 - 当持久性被禁用时,我看到使用指标 go 了。

Given the amount of testing I've done, I feel that I should be able to safely declare that Firestore must be recognizing my local cache and only charging me for Reads on updated documents.考虑到我所做的大量测试,我觉得我应该能够安全地声明 Firestore 必须识别我的本地缓存并且只对更新文档的读取收费。 However, I cannot find documentation around this anywhere, and I have combed through the docs.但是,我无法在任何地方找到关于此的文档,并且我已经梳理了文档。 I'd certainly think if Google wasn't charging me for these cached Reads that they would want to highlight that benefit, whereas they really only highlight enablePersistence as an offline benefit - so I am perplexed.我当然会认为,如果 Google 不为这些缓存的读取向我收费,他们会想要强调这一好处,而他们实际上只强调 enablePersistence 作为离线好处——所以我很困惑。

Does someone have some insight into what is going on here?有人对这里发生的事情有一些了解吗?

  • Example enable persistence: firebase.firestore().enablePersistence()示例启用持久性: firebase.firestore().enablePersistence()
  • Example query: myCollection.where(condition).get()示例查询: myCollection.where(condition).get()

According to this documentation根据这个文件

Offline data persistence 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离线数据持久化功能缓存您的应用正在使用的 Cloud Firestore 数据的副本,因此您的应用可以在设备离线时访问数据

So, it is clear that you will only be charged when calling get() on the server to-read documents, mentioned in this answer因此,很明显,只有在本答案中提到的在服务器上调用 get() 来读取文档时才会向您收费

Also, be aware that另外,请注意

  1. Offline Persistance is enabled by default for Android and iOS . Android 和 iOS默认启用离线持久性
  2. The pricing model for Cloud Firestore Cloud Firestore 的定价 model

This is a really great question.这是一个非常好的问题。 To clarify what the question is asking: "If my app is online and makes a query, but the query is fully returned by the offline cache, will I still be charged?"澄清问题的内容:“如果我的应用程序在线并进行查询,但离线缓存完全返回查询,我是否仍需付费?”

I suspect yes.我怀疑是的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM