1

I use firebase admin SDK in my nodejs server. If I download data of a certain realtime database path multiple times, it can be seen that the SDK downloads data of that path every time.

firebaseAdmin.database().ref('some/path').on('value', snapshot => {

});

If I use the firebase profiler, it is apparent that the SDK downloads data every time, since the profiler shows data usage for every time above code executes.

Is there any way to enable persistence of the realtime database data in admin SDK, so that the SDK will only download the delta when a change happened to that path?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Lahiru Chandima
  • 22,324
  • 22
  • 103
  • 179

1 Answers1

0

The Firebase Database clients for Android and iOS have two types of cache:

  1. An in-memory cache of all data that you currently have active listeners to. This cache also prevents having to re-download data for a location that is already in memory.
  2. An (optional) on-disk persistence that keeps the most recently downloaded data. When a listener is attached to a location that is in the disk cache, the initial data is loaded from disk to memory, after which only a delta is requested from the server.

The Firebase Admin SDK for Node.js does not implement disk persistence. It will download all data from a location each time you attach a listener to a location it doesn't have in memory yet.

I thought I'd seen this feature request before on the github repo, but can't it right now. It might be worth filing a feature request there, or with the Firebase support team.

For some more information on the disk persistence of the Firebase Realtime Database, see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807