java - Firestore 讲座操作计数

标签 java android firebase google-cloud-firestore nosql

我想了解 Firestore 如何计算读取操作。

firestore lecture operations

我有一个数据库和一个适用于移动设备的应用程序,因此无需执行任何操作即可使 Firestore 离线。 当我的应用程序打开时,用户从 | 的集合中接收数据。 n |文件。

我想了解即使数据库没有更改,通过互联网打开应用程序的用户是否也会从数据库执行读取操作? 或者每次访问如果没有变化,则不会添加读操作,因为数据仍然驻留在缓存中?

最佳答案

if a user who opens the application with the internet on will perform read operations from the database even if there are no changes in the database?

如果您使用 get() 调用,Firestore SDK 将始终尝试从服务器获取数据,无论数据是否更改。 设备离线时,您才可以使用缓存中的数据。但是,如果您尝试使用 SnapShotListener 实时监听更改,根据官方文档:

The initial state can come from the server directly, or from a local cache. If there is a state available in a local cache, the query snapshot will be initially populated with the cached data, then updated with the server's data when the client has caught up with the server's state.

换句话来说,如果服务器说你没有新添加/更新/删除的文档,你就从缓存中获取数据。但是,关于 the duration of time you can get the data from cache 还有一些您应该注意的事情。 :

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.

Another possible charge might also come from :

There is a minimum charge of one document read for each query that you perform, even if the query returns no results.

但根据 Firestore 的设计方式,所有这些费用都是正常的。

关于java - Firestore 讲座操作计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61456574/

相关文章:

java - 如何使用Java程序访问Linux全局变量

java - Firebase:Recyclerview 未连接适配器,跳过布局

java - 我的 Java 程序没有在整个窗口上绘制矩形

android - 在外部应用程序中打开 pdf

android - Firebase 数据上传崩溃的 Android 应用程序

java - 生产JVM的安全调试

android - 无法解析类型 'visibility' 上的双向绑定(bind)属性 'android.support.constraint.Group'

android - 在我自己的 REST API 上验证从 Facebook 收到的凭据

firebase - 如何协调 Firebase Auth token 刷新与服务器端呈现

swift - 如何实现 firebase 事务