简体   繁体   English

如何在本地删除firebase中查询到的数据?

[英]How do you delete queried data from firebase locally?

In my react native app, users are able to create and see posts (that can contain media) which are stored in Firebase's realtime database.在我的 react native 应用程序中,用户可以创建和查看存储在 Firebase 实时数据库中的帖子(可以包含媒体)。 It works correctly, however the size of the app increases greatly over time, which I assume is because more and more posts are queried and stored.它可以正常工作,但是随着时间的推移,应用程序的大小会大大增加,我认为这是因为越来越多的帖子被查询和存储。 Is this likely to be what causes the increased size of the app?这可能是导致应用程序大小增加的原因吗? If so, is it possible to delete such local data in the componentDidMount function?如果是这样,是否可以删除componentDidMount function中的此类本地数据?

There is no API to tell Firebase to clear its cache.没有 API 告诉 Firebase 清除其缓存。 But if you find that the size of the cache grows beyond what is reasonable for your app, you can explicitly set the cache size to something that works better for your users.但是,如果您发现缓存的大小超出了您的应用程序的合理范围,您可以明确地将缓存大小设置为更适合您的用户的大小。

A few notes:几点注意事项:

  • Storing images in the JSON database is in general not recommended, for many reasons.通常不建议将图像存储在 JSON 数据库中,原因有很多。 But one of them is precisely because those image would disproportionally affect the cache size.但其中之一正是因为这些图像会不成比例地影响缓存大小。 Consider storing the images in a dedicated file storage solution, like Cloud Storage for Firebase, and using a image-caching library.考虑将图像存储在专用文件存储解决方案中,例如用于 Firebase 的 Cloud Storage,并使用图像缓存库。
  • Firebase's local persistence functions as a cache. Firebase 的本地持久性用作缓存。 You should not treat Firebase as a purely local database, as its local performance will deteriorate over time as the cache grows.您不应将 Firebase 视为纯粹的本地数据库,因为随着缓存的增长,其本地性能会随着时间的推移而下降。 If your clients never connect to the Firebase servers, you might want to consider using another database, which is optimized for pure local usage.如果您的客户端从未连接到 Firebase 服务器,您可能需要考虑使用另一个数据库,该数据库针对纯本地使用进行了优化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检索自动生成的 ID 以删除 firebase 中的数据 - how do you retrieve a auto generated id to delete data in firebase 你如何使用android studio在本地存储应用程序数据? - How do you store app data locally using android studio? 如何在ListView中以及从Firebase中删除数据? - How to delete data in ListView and also from Firebase? 如何从 firebase android 中删除数据 - How to delete data from firebase android 如何从TextView替换数据,而不是从Firebase数据库添加到TextView? - How do you replace data from a TextView instead of adding to the TextView from a firebase database? 如何在onBindViewHolder中将查询的数据分配给String或int? - How do I assign a queried data to a String or int in onBindViewHolder? 我想将表单中的用户输入与查询的数据进行比较。 但我希望它不区分大小写。 我怎么做? - I want to compare the user input from my form to the queried data. but I want it not to be case sensitive. how do I do that? 从 android firebase 中删除数据 - delete data from android firebase 如何允许用户从Firebase删除其帖子? - How do I allow users to delete their post from Firebase? 如何允许用户从Firebase删除自己的帖子? - How do I allow users to delete their own post from Firebase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM