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?

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.