由于 Firebase UI,我的应用程序缓存增加

Cache of my application increases due to Firebase UI

我正在开发一个即将在本周末发布的应用程序。但是我发现我的应用程序有一件奇怪的事情。当我检查应用程序的存储信息时,我发现我的应用程序的缓存数据在加载数据时迅速增加。我正在使用 Firebase UI 将 Cloud Firestore 中的数据加载到我的 Recycler View 中。这也包含图像。我以某种方式得出结论,这都是因为从服务器获取的图像被重复下载,这增加了我的缓存。我想知道如何减少缓存大小,因为它现在消耗了大量用户的存储空间。

如果您想限制缓存的大小,您需要在执行任何查询之前进行设置。 documentation for configuration the cache size 表示您可以像这样使用 setCacheSizeBytes()

When persistence is enabled, Cloud Firestore caches every document received from the backend for offline access. Cloud Firestore sets a default threshold for cache size. After exceeding the default, Cloud Firestore periodically attempts to clean up older, unused documents. You can configure a different cache size threshold or disable the clean-up process completely:

FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
        .setCacheSizeBytes(FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED)
        .build();
db.setFirestoreSettings(settings);