Java Firestore 客户端库的 FireStore 或 FireStoreClient 类?

问题描述 投票:0回答:1

我刚开始使用 Google Cloud Firestore(不带 Firebase),只是为了让我的 Cloud Functions 在执行之间保留某些状态数据。

我很困惑 FirestoreClient 类和 FireStore 类有什么区别?

两个文档都说它们是“firestore 客户端”,哦,好吧,一个说它是“Firestore 服务器客户端”,这是同一件事,对吗?它们都只是在 Firestore 数据库中添加、更新、检索和删除数据的编程接口?

FireStoreClient
类似乎可以直接获取、更新和列出文档,而
FireStore
类似乎对DocumentReference或QueryDocumentSnapshot进行操作?老实说,我很困惑,这意味着什么,不确定我应该看哪一个?

顺便说一句,我真的只需要一个数据库作为我的云函数执行之间的持久层,我存储的只是 3 个键值对字符串,但可靠的持久性很重要,即使用像 MemoryStore 这样的东西,即使它是轻量级的并且更简单的界面,但有丢失数据的风险,因为它不像 FireStore 那样耐用。如果我在这里打错电话,请告诉我,谢谢!

google-cloud-platform google-cloud-firestore google-cloud-functions
1个回答
0
投票

可以看到,FirestoreClient类和Firestore接口之间没有继承关系。所以

FirestoreClient
不是
Firestore
。但是,两者共享相似的方法,可以帮助您与 Firestore 交互。

但是也存在一些差异。

Firestore
接口代表 Firestore 数据库入口点,并提供对 Firestore 数据库操作的直接访问。另一方面,
FirestoreClient
类提供了对支持服务进行远程调用的能力。除此之外,还请注意
Firestore
接口属于 com.google.cloud.firestore 包,而
FirestoreClient
类属于 com.google.cloud.firestore.v1 (版本 1)包。

现在,根据应用程序的用例,您应该选择最适合执行 Firestore 数据库调用的选项。

© www.soinside.com 2019 - 2024. All rights reserved.