本文介绍了如何防止Flubase应用程序中的Firebase Firestore进行不必要的读取操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在我的Firestore数据库中,我有大约2000个文档,其中包含带有一些标签的图像(blob),以对它们进行分组,排序并在本地设备上进行搜索.在我的应用程序中,图像存储在本地SQLFlite数据库中,用户可以离线查看它们,还启用了Firestore离线持久性.启用设备网络连接后,firestore监听器会再次读取所有查询,因为即使我的Firestore数据库中没有任何更改,我的应用程序也会根据用于对图像进行分类的标签显示我的图像.主要原因是30分钟规则:

So in my Firestore db, I have about 2000 documents that contain images (blob) with some tags to group them, order them and search them on local device. In my app, images are stored in a local SQLFlite db and user is able to see them offline, Firestore offline persistance is also enabled. When device network connection is on, firestore listener reads all my queries again because my app shows my images according to the tags that I use to classify images, even if there is no changes in my Firestore db. Main reason for this is the 30 minutes rule:

因此,当我的本地数据库和firestore数据库没有变化时,在最坏的情况下,我将每30分钟支付一次由我的图片标签引起的所有查询,这可能会导致最多10000次用户读取

So, when my local and firestore db's does not change, I will be charged for all the queries caused by the tags of my images in every 30 minutes in the worst case, which may cause about 10000 reads for a user at max.

当我们谈论最大时,我们低估了最小"情况.如果用户每天打开我的应用4次,则可能导致1000次读取,我认为这也很昂贵.

When we talk about maximum, we underestimate the "minimum" scenario. If user opens my app 4 times a day, it may cause 1000 reads, which I think is also expensive.

我正在考虑一些解决方案:1-在打开应用程序时是否可以通过一些代码禁用Flutter应用程序网络连接?例如,如果应用程序打开时有网络连接,则在接下来的24小时内,无论电话网络连接是否打开/关闭,应用程序都将无法连接互联网.2-有其他选择吗?

I am considering about some solutions:1- any way to disable a Flutter apps network connection with some code while opening the app? For example if there is a network connection at the time an app opens, in the next 24 hours the app won't be able to connect the internet whether or not phones network connection is turned on/off.2- any alternatives?

我知道我有点滥用Firestore,但是我的数据库每天可能会更改一次,那么为什么每30分钟一遍又一遍地读取每个查询?作为一名业余开发人员,非常感谢任何想法.

I know that I am kind of mis-using Firestore, but my database will probably change once in a day, so why reading every query over and over again in every 30 minutes?As an amateur developer, any idea is appreciated, thanks a lot.

EDİT:3-如何使用实时数据库+云存储,而不是将Firestore与Blob编码的图像一起使用?我不知道实时数据库是否有一些被动的计费方式,例如Cloud Firestore中的30分钟规则.

EDİT:3- how about using realtime database + cloud storage instead of using Firestore with blob encoded images? I don't know if realtime db has some passive ways of billing like 30 minutes rule in Cloud Firestore.

推荐答案

好问题.那么,为什么不在应用程序状态下存储上次请求数据的时间戳,然后在应用程序重新启动时仅存储此后创建/修改的请求数据呢?

Good question. So why don't you store the timestamp of then you last requested data in your application state, and then when the app restarts only request data that was created/modified since then?

这篇关于如何防止Flubase应用程序中的Firebase Firestore进行不必要的读取操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 10:28
查看更多