检索已脱机缓存的文档是否将被视为已读? [英] Will retrieving a document that is already cached offline will count as read?

查看:38
本文介绍了检索已脱机缓存的文档是否将被视为已读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,每次用户打开其个人资料页面时,该应用程序都会获得一个文档,其中包含Firestore的个人资料信息.因此,用户首次打开应用程序时,它将从Firestore服务器下载文档,然后将其离线缓存在设备上(打开离线持久性).现在,假设用户关闭了该应用程序,然后再次打开它,仍然在线,打开其配置文件页面,并且用户文档没有更改.Firestore会从缓存中检索文档吗?还是它将再次从Firestore下载(并计为另一次读取)?

In my app that everytime the user opens its profile page, the app will get a single document containing it profile information for Firestore. So the first time the user will open the app it will download the document from Firestore server and then it cached offline on the device (offline persistence turn on). Now let say that user closes the app and open it again, still online, open its profile page, and user document didn't change. Will Firestore retrieve the document from the cached? Or will it download it again from Firestore (and count as another read)?

推荐答案

本地持久性的全部目的是缓存以前读取的文档,以便将来不再需要从服务器读取其他文档.因此,不,SDK不应第二次从服务器读取文档.

The whole point of local persistence is to cache documents previously read, so that they don't require another read from the server in the future. So, no, the SDK should not read the document from the server the second time.

您可以通过检查元数据来亲自验证与该文档相关联,以查找是否已获得该文档 fromCache .

You can verify this for yourself by checking the metadata associated with the document to find if it was obtained fromCache.

这篇关于检索已脱机缓存的文档是否将被视为已读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆