如何将Firebase数据库持久性存储限制为仅某些节点? [英] How to limit Firebase database persistence store to only some nodes?

查看:60
本文介绍了如何将Firebase数据库持久性存储限制为仅某些节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将以下代码添加到 AppDelegate 将使用户离线时Firebase数据库可用:

Adding the following code to the AppDelegate will make the Firebase database available when the user is off-line:

FIRDatabase.database().persistenceEnabled = true

我们如何才能使数据库的某些部分以脱机模式可用,而某些部分仅在用户在线时可用?

How can we make just some parts of the database available in off-line mode and some parts available just when the user is on-line?

推荐答案

简短的回答:您不能.Firebase当前不提供这种细粒度的持久性范围API.

Short answer: you can't. Firebase don't currently provide such a fine grained persistence scope API.

您可以做的是减少/增加持久性缓存使用的磁盘空间量.默认情况下,它将使用最多 10MB 的磁盘空间来缓存数据(顺便说一句,按今天的标准,这是少量的).这由 FIRDatabase控制.persistenceCacheSizeBytes 属性.

What you can do instead is decrease/increase the amount of disk space used by the persistence cache. By default, it will use up to 10MB of disk space to cache data (a small amount by today standards, by the way). This is controlled by the FIRDatabase.persistenceCacheSizeBytes property.

例如,使用更大的缓存可能会容纳所需子集中的更多节点...如果幸运的话:)

For instance, using a larger cache might hold more nodes from your desired subset... if you are lucky :)

相反,较小的值可能会在很大程度上影响您的网络性能/成本.

Conversely, a smaller value might affect your network performance/cost in significant ways.

这篇关于如何将Firebase数据库持久性存储限制为仅某些节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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