Firebase keepSynced (true)

What are the tradeoffs when I use multi-path synchronization in my Firebase database?

databaseRef.keepSynced(true); 

I never clear synchronization from these paths.

Alternatively, I can call databaseRef.keepSynced (true); several times along the same path. This is problem?

I also use

 FirebaseDatabase.getInstance().setPersistenceEnabled(true); 

So, what can I "pay" for this synchronization in terms of battery life, memory?

+9
source share
1 answer

When you use the keepSynced() method, you tell Firebase to load and cache all the data from databaseRef . I hope that databaseRef not the root directory of your database, because if so, you are loading your entire database, and that is not a good practice.

You must use keepSynced() to cache the nodes that are really needed to run your application offline.

You might be wondering how it differs from setPersistanceEnabled(true) . Well, setPersistanceEnabled(true) caches data only when setPersistanceEnabled(true) connected to this node when the data has been read at least once).

On the other hand, keepSynced(true) caches everything from this node, even if a listener is not connected to it.

+7
source

Source: https://habr.com/ru/post/1013777/


All Articles