问题
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?
回答1:
Short answer: you can't. Firebase don't currently provide such a fine grained persistence scope API.
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.
来源:https://stackoverflow.com/questions/44086631/how-to-limit-firebase-database-persistence-store-to-only-some-nodes