如何才能避免数千美元的 Firebase 账单?
我正在建立医院管理应用程序。在此应用中,有许多功能,其中主要功能是消息传递,预约预订,视频预约等。 在消息传递功能中,我要做的是使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论