Choosing between legacy setPersistenceEnabled and FirebaseDatabaseSettings.Builder for persistence in Firebase Realtime Database SDK 10.x
0 reputation · 18 Jul 2023, 06:34 UTC
Goal: Enable disk‑based persistence for Firebase Realtime Database while supporting apps that use multiple FirebaseApp instances or custom FirebaseApp configurations.
Constraint: In SDK 10.x the persistence flag moved from FirebaseDatabase.getInstance().setPersistenceEnabled(...) to FirebaseDatabaseSettings.Builder.setPersistenceEnabled(...), but the legacy method remains available for backward compatibility. It is unclear whether the two approaches behave identically when a non‑default FirebaseApp is used, and whether they differ in flush latency or cache eviction under intermittent connectivity.
Questions: Does invoking the legacy setPersistenceEnabled on a FirebaseDatabase obtained from a secondary FirebaseApp share the same persistence cache as the default app? Does the builder‑based approach require a separate FirebaseDatabase instance per FirebaseApp, and how does that affect memory usage? Are there measurable differences in write‑flush latency or cache eviction behavior between the two methods when the network drops and reconnects repeatedly?