Sreekanth Karumanaghat
Sreekanth Karumanaghat

Reputation: 3403

Where does the firebase listeners listen to RAM or disk?

In the following code:-

 String FirebaseRefer = Constants.Client + "/" + Constants.firebaseProjects + "/" + Constants.name + "/xyz";
DatabaseReference agendaRef = FirebaseDatabase.getInstance().getReference(FirebaseRefer);
agendaRef.keepSynced(true);    

agendaRef.addListenerForSingleValueEvent(new com.google.firebase.database.ValueEventListener() {

    @Override
    public void onDataChange(com.google.firebase.database.DataSnapshot snapshot) {

where does the firebase listener listen to? Is it the firebase data in the RAM or to that in the disk?

Upvotes: 1

Views: 191

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

The Firebase Database client keeps a copy of all data that you're listening to in memory of your app. Once you remove the last listener for a location, the data is removed from memory. Since you call agendaRef.keepSynced(true), this means that all data at agendaRef is kept in memory, and kept up to date.

If you enable persistence the client will also persist active and recent data to disk.

Upvotes: 3

Alex Mamo
Alex Mamo

Reputation: 138824

When we are talking about listeners, actually we are talking about the number of read/writes operations that you do in a certain time, the number of read/writes you do per second because every disk has a maximum number of I/O (input/output operations) per second. When it comes to Firebase, the Firebase database is not different. So, to answer your question, Firebase listeners listen on the disk.

One thing to rememebr, beeing on shared infrastructure, the number of IOPS is not guaranteed.

Upvotes: 0

Related Questions