好的,我刚刚开始研究 Firebase。所以说我想填充一个简单的表格 View 。看来我只能访问异步方法来访问其本地缓存?这是正确的吗?
所以这意味着我需要回调,然后填充我自己的内存缓存,然后 tableview 委托(delegate)方法可以访问它?那么现在我们实际上拥有相同数据的两个缓存?或者我在这里遗漏了什么?
最佳答案
Cloud Firestore 客户端会在应用的内存中保留您正在收听的所有数据的副本。删除某个位置的最后一个监听器后,数据将从内存中删除。
因为在 Firestore 中,offline persistence默认启用:
For Android and iOS, offline persistence is enabled by default. To disable persistence, set the
PersistenceEnabled
option tofalse
.
客户端还将事件和最近的数据保存到磁盘。
并回答您的问题:
It seems that I only have access to async methods to access its local cache?
是的,没错。
So this means I need to callback and then populate my own in-memory cache that in turn the tableview delegate methods can then access?
你也是对的。
So now we effectively have two caches of the same data?
只要监听器处于事件状态,是的,您将拥有两个缓存。
关于swift - 使用 Swift 同步访问 Firebase Cloud Firestore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54949024/