相关疑难解决方法(0)

关于firestore缓存和读取费用的问题

我了解 firestore 缓存和读取费用在这些场景中的表现。我不确定这是否正确。

如果我在一个集合中有 2000 个文档。此集合名称为“testCollection”。这些文档不会更改、更新或删除。我的客户端是 android 已经启用离线持久性和设备当前在线

1.

db.collection("testCollection").onSnapshot(function(doc) {});

收取 2000 次读取费用并缓存这些文档。然后重新打开应用程序并再次运行相同的代码

db.collection("testCollection").onSnapshot(function(doc) {});

另外 2000 次读取收费,因为 firestore 需要检查每个文档是否是最新的。所以 2000+2000 次读取收费

2.

我不确定这是如何表现的。只需一起运行相同的代码

db.collection("testCollection").onSnapshot(function(doc) {}); 
db.collection("testCollection").onSnapshot(function(doc) {});
Run Code Online (Sandbox Code Playgroud)

我认为 2000 次读取是收费的,因为数据是最新的

3.

db.collection("testCollection").limit(300).onSnapshot(function(doc) {}); 
db.collection("testCollection").limit(800).onSnapshot(function(doc) {}); 
Run Code Online (Sandbox Code Playgroud)

总共 1100 次读取收费。因为它是不同的查询。

我有什么误解或错误吗?

firebase google-cloud-firestore

8
推荐指数
1
解决办法
671
查看次数

标签 统计

firebase ×1

google-cloud-firestore ×1