了解缓存的Firestore快照读取的定价模型

huangapple go评论53阅读模式
英文:

Understanding pricing model for cached Firestore snapshot reads

问题

I'll provide the translated content without additional information:

  1. 应用程序第一次启动(假设:20次读取操作,因为没有可用的缓存数据)
  2. 应用程序关闭并再次打开。期间未进行任何更改(假设:0次读取操作,因为可以从缓存中获取数据)
  3. 用户滚动。旧的快照监听器被替换为一个新的,其中限制增加到40。期间未进行任何更改(假设:20次读取操作,因为在缓存中已经有20次读取操作)
  4. 数据库发生更改(假设:1次读取操作)

这些假设基于这个stackoverflow帖子

但是,由Firebase团队制作的这个解释视频(在8:05处)解释说,情况3会耗费40次读取操作。这是真实情况,还是解释有些误导?

如果这些假设是正确的,那么库是如何知道在情况2下不需要进行新的读取操作的?

英文:

Lets say I am persisting movies in a collection with a createdAt property. My android app wants to show all recently added movies in a list by querying this collection with an orderBy statement on the createdAt. I also add a limit 20 at the initial request, and increase this when user scrolls dynamically.

Are these pricing model assumptions correct for these situations:

  1. App is getting started the first time (assumption: 20 read ops because no cached data was available)
  2. App gets closed and opened again. No changes are made in the meanwhile (assumption: 0 read ops since data can get fetched from the cache)
  3. User scrolls. Old snapshot listener gets replaced with a new one where the limit is increased to 40. No changes are made in the meanwhile (assumption: 20 read ops, since there already were 20 known in cache before)
  4. Change is made to db. (assumption: 1 read op)

These assumptions are made based on this stackoverflow post.

But this explanation video (at 8:05) made by the firebase team themselves explains that the case 3 would cost me 40 read ops though. Is this true or is it explained a bit misleading ?

And if the assumptions were correct, how does the library know that there is no need to make new read ops at case 2.?

答案1

得分: 2

以下是翻译好的部分:

Is this true or is it explained a bit misleading?

这是真的。当您附加新的监听器时,它会查询新文档,查询结果不会来自缓存(除非应用程序离线)。缓存主要用于处理离线情况。

how does the library know that there is no need to make new read ops at case 2.?

它不知道。它会执行全新的查询。

英文:

> Is this true or is it explained a bit misleading ?

It is true. When you attach a new listener, it will query for new documents and the query results will not come from cache (unless the app is offline). The cache is primarily in place to handle offline conditions.

> how does the library know that there is no need to make new read ops at case 2.?

It doesn't. It does a whole new query.

huangapple
  • 本文由 发表于 2023年6月18日 21:04:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76500688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定