简体   繁体   中英

How do I set the cache size of FirebaseDatabase in the new FirebaseDatabase API for Android?

How do I set the cache size of FirebaseDatabase in the new FirebaseDatabase API for Android?

I am just updating my legacy code to the new version, the old setup would be:

    Firebase.setAndroidContext(this);
    Config config = Firebase.getDefaultConfig();
    config.setPersistenceEnabled(true);
    config.setPersistenceCacheSizeBytes(50 * 1000 * 1000);
    Firebase.setDefaultConfig(config);

The new code as described in documentations is only

    FirebaseDatabase.getInstance().setPersistenceEnabled(true);

But class FirebaseDatabase does not have a method like setPersistenceCacheSizeBytes() as described in this reference: https://firebase.google.com/docs/reference/android/com/google/firebase/database/FirebaseDatabase The new documentation states that the default size is 10Mb, but it does not tell me where to change this default value.

There is a setPersistenceCacheSizeBytes() method. I don't know when this was added, though.

此行适用于我设置持久性缓存大小。

FirebaseDatabase.getInstance().setPersistenceCacheSizeBytes(50 * 1000 * 1000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM