Android上的Cloud Firestore离线持久性可靠性 [英] Cloud Firestore offline persistence reliability on Android

查看:31
本文介绍了Android上的Cloud Firestore离线持久性可靠性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android应用程序中使用Firebase的Cloud Firestore接收产品信息.Android客户端仅从Firestore读取,而从不写入.脱机持久性已启用.产品信息每周更新一次.

I'm using Firebase's Cloud Firestore in an Android application for receiving product information. The Android client only reads from Firestore and never writes. Offline persistency is enabled. The product information is updated once a week.

我收到了几份客户报告,声称即使在我更改了云中的数据之后,他们仍然看到过时的数据.这些报告甚至在导入后的几天内就会出现,因此我想他们的智能手机同时已连接了互联网,这不是连接问题.

I've received several reports of customers that claim that they still see outdated data even after I've changed the data in the cloud. These reports come in even days after the import so I guess their smartphone had an Internet connection in the meantime and it's not a connectivity issue.

重点是我永远无法重现这一点.我已经检查了几次代码,但没有发现任何错误.呈现视图时,我正在从Firestore 一次阅读.我不使用快照侦听器.

The point is I could never reproduce this. I've checked the code a few times but don't see any error on my side. I'm reading from Firestore once when the view is rendered. I do not use snapshot listeners.

我知道这都很模糊,所以我只是问是否有人在启用了离线持久性的情况下在Android上使用Firestore具有相同的体验?

I know this is all very vague so I'm just asking if anyone else made the same experience with Firestore on Android with offline persistency enabled?

Firestore库的版本为17.1.5.

Version of the Firestore library is 17.1.5.

推荐答案

不过,我没有遇到相同的问题,只是为了帮助(也许很有用),这里没有提到Cloud Firestore的工作方式:

I haven't had the same problem, however, just to help (maybe it's useful), few things to mention here, about how Cloud Firestore works:

  1. 第一次获取客户端SDK时,它会从服务器获取,并将结果保存到缓存中.
  2. 第二次获取时,第一个结果将始终来自缓存,直到您从服务器获取它们为止.
  3. 在您从服务器获取新值之前,它们将一直来自缓存.

您具有诸如 Source.SERVER Source.Cache 之类的规范.如果您无法真正重现此内容,那么我可能会认为这与您的客户关系有关.但是,为了让您实际调试并查看所发生的百分比,我建议您(以实际查看影响并更多地由数据驱动):

You have specifications such as Source.SERVER or Source.Cache. If you can't really reproduce this, I might really think that this is something to do with the connection of your customers. However, for you to actually debug this and see the percentage of this happening, I would suggest you to (to actually see the impact and be more data-driven):

  1. 每当您更新信息时(按您说的每周一次),将时间戳对象添加到Firestore中.
  2. Firebase远程配置添加相同的时间戳
  3. 在客户端中获取这些内容并进行比较(如果不相同),并且如果从Remote Config中获得的结果永远不会出现,则意味着您遇到了具有上述问题的用户组.

只是一个虚拟测试,您可以实际看到其影响.从我当前的PoV来看,我不能为您提供更多帮助.但是,我也建议您在Cloud Firestore上提高版本,目前是21.3.0.

Just a dummy test for you to actually see the impact. From my current PoV, I can't help you more than this. However, I would also urge you to bump up your versioning on Cloud Firestore, currently, it's 21.3.0.

这篇关于Android上的Cloud Firestore离线持久性可靠性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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