Cloud Firestore - 实时侦听器更新是否算作读取操作?
Cloud Firestore - does a realtime listener update count as a read operation?
假设我正在听文档:
db.collection("cities").document("SF")
.addSnapshotListener { documentSnapshot, error in
guard let document = documentSnapshot else {
print("Error fetching document: \(error!)")
return
}
print("Current data: \(document.data())")
}
根据 Firestore billing policy,每次更新数据算作读取操作,还是监听行为本身算作?
此外,假设我正在听一些文件:
db.collection("cities").whereField("state", isEqualTo: "CA")
.addSnapshotListener { querySnapshot, error in
guard let documents = querySnapshot?.documents else {
print("Error fetching documents: \(error!)")
return
}
let cities = documents.map { [=11=]["name"]! }
print("Current cities in CA: \(cities)")
}
我是否会立即对与查询匹配的所有文档或对每个文档的每次更新(或两者)的读取操作收费?
收听行为本身不算作阅读,但每次查询至少收取一份文档费用。在定价页面的“最低查询费用”下:
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
初始读取和更新都算在内。但是,如果您在收听后不久重新收听,您将不会为自上次收听以来未更改的文档付费。目前,该短暂阈值是 30 分钟。也在那里,在“监听查询结果”下:
When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated
Also, if the listener is disconnected for more than 30 minutes (for example, if the user goes offline), you will be charged for reads as if you had issued a brand-new query.
假设我正在听文档:
db.collection("cities").document("SF")
.addSnapshotListener { documentSnapshot, error in
guard let document = documentSnapshot else {
print("Error fetching document: \(error!)")
return
}
print("Current data: \(document.data())")
}
根据 Firestore billing policy,每次更新数据算作读取操作,还是监听行为本身算作?
此外,假设我正在听一些文件:
db.collection("cities").whereField("state", isEqualTo: "CA")
.addSnapshotListener { querySnapshot, error in
guard let documents = querySnapshot?.documents else {
print("Error fetching documents: \(error!)")
return
}
let cities = documents.map { [=11=]["name"]! }
print("Current cities in CA: \(cities)")
}
我是否会立即对与查询匹配的所有文档或对每个文档的每次更新(或两者)的读取操作收费?
收听行为本身不算作阅读,但每次查询至少收取一份文档费用。在定价页面的“最低查询费用”下:
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
初始读取和更新都算在内。但是,如果您在收听后不久重新收听,您将不会为自上次收听以来未更改的文档付费。目前,该短暂阈值是 30 分钟。也在那里,在“监听查询结果”下:
When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated
Also, if the listener is disconnected for more than 30 minutes (for example, if the user goes offline), you will be charged for reads as if you had issued a brand-new query.