问题
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
This statement persists all the read and write operations in firebase database across the app restarts. But what i need to exclude some of my database nodes from being persisted?
I am already storing the data in local database, and enabled the persistence only for the database write operations. Some of my queries are downloading a big amount of data for displaying some reports to the user and I want Firebase to exclude that query from being cached.
Is there a preferred way to do this; or how can we persist only the database write operations?
回答1:
This statement persists all the read and write operations in firebase database across the app restarts.
It doesn't persist all of these things. It will persist up to 10MB of the most recently read data. That limit does not apply to the data you've written that has not yet been synchronized.
You don't have any ability to exclude any paths from persistence if this feature is enabled.
If you want to read something from the database without allowing it to hit the persistence cache, consider reading it via the REST API instead of through the SDK.
来源:https://stackoverflow.com/questions/43463188/how-to-exclude-some-of-the-firebase-database-nodes-from-being-persisted