简体   繁体   English

Firebase Firestore 是否计算同一文档的读取次数?

[英]Does Firebase Firestore count reads of the same document?

As I understand, when we call get() on some reference, Firebase gets lastest snapshot of this document from Firestore.据我了解,当我们在某个引用上调用get()时,Firebase 会从 Firestore 获取该文档的最新快照。

So my question is: If at the beginning of app (for example in some init) I call something like firestore.collection(food).doc(pizza).get().data() and it gives me some Snapshot of this document where I get data.所以我的问题是:如果在应用程序的开头(例如在某些初始化中)我调用类似firestore.collection(food).doc(pizza).get().data() ,它给了我这个文档的一些快照我在哪里获取数据。

Lets say, later in app, I call the same reference firestore.collection(food).doc(pizza).get().data() in some side effect of completely different method and read this data again.可以说,稍后在应用程序中,我在完全不同的方法的某些副作用中调用相同的引用firestore.collection(food).doc(pizza).get().data()并再次读取此数据。 Before this, the document didn't change.在此之前,文档没有改变。

Will Firebase count this as one or two reads? Firebase 会将此视为一两次读取吗?

Each get() will obtain a new snapshot of the document, as long as there is internet connectivity.只要有 Internet 连接,每个get()都会获取文档的新快照。 If the app is offline, the SDK will attempt to use the local cache instead.如果应用离线,SDK 将尝试使用本地缓存。

If you want to understand in more detail about how the cache works, read this blog post .如果您想更详细地了解缓存的工作原理,请阅读这篇博文

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

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