如何降低Firebase实时数据库下载成本? [英] How to reduce firebase realtime database download cost?

查看:127
本文介绍了如何降低Firebase实时数据库下载成本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firebase实时数据库中建立2个数据库是否有助于降低成本并增加每天360MB的每日下载限制?

Will making 2 database in firebase realtime database help to reduce cost and increase daily download limit of 360MB per day?

推荐答案

降低成本的最简单方法是减少下载量.为此,您可以尽可能地将数据缓存在本地存储中,并持续同步敏感数据.

The simplest way to reduce the cost is by reducing the downloads. You can do that by caching the data on local storage as much as possible and continuously sync sensitive data.

在阅读不同的文章时,有一篇文章引起了我的注意.我将总结我的发现,并在文章中添加链接.

While reading different articles, one article caught my eye. I'll summarize my findings and also add the link to the article.

可能的优化:

  1. 优化存储在数据库中的序列化数据,这可以通过GSON轻松实现,GSON是一个处理JSON数据的库,该库允许使用注释更改序列化实体的名称.(还有许多其他库可以执行相同的操作) GSON @SerializedName
  2. 实施内存缓存,该缓存仅在应用程序的生命周期内保留.该缓存的工作方式如下:
  1. Optimize serialized data saved in the database, this can be achieved easily with GSON, a library to handle JSON data that allows changing the name of serialized entities with annotations. (There are many other libraries that can do the same) GSON @SerializedName
  2. Implementing a memory cache that is kept only during the life of the App. This cache works as follows:

  • 用户打开应用程序,然后在应用程序中的某个位置列出了任何收藏夹,例如公交车站的收藏夹".
  • 该应用程序向内存缓存请求公交车站"收藏夹列表,但由于该应用程序刚刚启动,因此返回null.
  • 然后,该应用仅向Firebase请求包含公交车站收藏夹"的节点,该节点是从互联网上下载的,然后计费一次.
  • 此收藏夹的副本保存在内存缓存中.
  • 用户使用收藏夹进行播放,添加,删除或编辑它们.
  • 每次修改完成后,生成的收藏夹列表都会保存在内存缓存中,并且还会发送到Firebase(因为上传数据是免费的).
  • 现在,用户可以离开该应用程序,并且除非该应用程序被用户从最近的应用程序堆栈中明确删除或被Android杀死,否则该用户可以返回该应用程序并继续使用公交车站"收藏夹,而不会引起额外计费.

链接到文章提到. 希望这会有所帮助!!

Link to the article mentioned. Hope this helps!!!.

这篇关于如何降低Firebase实时数据库下载成本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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