Milligator
Milligator

Reputation: 159

How to limit Firebase database persistence store to only some nodes?

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?

Upvotes: 2

Views: 299

Answers (1)

Paulo Mattos
Paulo Mattos

Reputation: 19339

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.

Upvotes: 1

Related Questions