如何才能避免数千美元的 Firebase 账单?

发布于 2025-01-20 21:42:41 字数 727 浏览 1 评论 0原文

我正在建立医院管理应用程序。在此应用中,有许多功能,其中主要功能是消息传递,预约预订,视频预约等。 在消息传递功能中,我要做的是使用Bellow代码加载来自CACHE的所有先前消息

QuerySnapshot<Map<String, dynamic>> localMessageDocs = await _db
    .collection("users")
    .doc(AuthService.uid())
    .collection("messages")
    .orderBy('time', descending: true)
    .get(GetOptions(source: Source.cache));

,之后我使用以下代码来查询最新消息,

 _db
    .collection('users')
    .doc(AuthService.uid())
    .collection('messages')
    .where('time', isGreaterThan: _lastLocalMessageTime)
    .orderBy('time', descending: true)
    .snapshots()

但我仍然担心如果此系统失败,可能会发生大量读取,例如在Android和Firebase缓存限制中允许的缓存尺寸(默认为40MB),因为单用户的消息可能会呈指数增加,这可能会导致千美元的账单。 任何帮助将不胜感激!

I am building a hospital management app. In this app there are bunch of features of which major features are messaging, appointment booking, video appointment and much more.
In the messaging feature what I am trying to do is loading all the previous messages from cache using bellow code

QuerySnapshot<Map<String, dynamic>> localMessageDocs = await _db
    .collection("users")
    .doc(AuthService.uid())
    .collection("messages")
    .orderBy('time', descending: true)
    .get(GetOptions(source: Source.cache));

and after that I am querying latest messages using below code

 _db
    .collection('users')
    .doc(AuthService.uid())
    .collection('messages')
    .where('time', isGreaterThan: _lastLocalMessageTime)
    .orderBy('time', descending: true)
    .snapshots()

but still I am afraid of bunch of reads that may occur if this system fails, like the cache size allowed in android and the firebase cache limitations(Default is 40MB) as messages for single user can be increase exponentially, which may cause thousand dollar bill.
Any help will be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文