库 appengine.api.datastore 和 com.google.cloud.datastore 有什么区别?
What is the difference between libraries appengine.api.datastore and com.google.cloud.datastore?
我正在开发一个应用引擎项目并使用 Google 数据存储存储我的数据。我使用的是不同的数据存储库,因为它们是示例中使用的库,但我发现我必须同时使用这两个库有点奇怪:
如果我查看文档进行查询,在这个例子中他们使用这个库来处理查询:
com.google.appengine.api.datastore
https://cloud.google.com/appengine/docs/java/datastore/retrieving-query-results
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
PreparedQuery pq = datastore.prepare(q); Entity result =
pq.asSingleEntity();
然而,在这个例子中存储数据,他们使用
com.google.cloud.datastore
https://cloud.google.com/datastore/docs/concepts/entities
Entity task = Entity.builder(taskKey)
.set("category", "Personal")
.set("done", false)
.set("priority", 4)
.set("description", "Learn Cloud Datastore")
.build();
现在我可以同时使用两者,但我想知道哪一个更适合哪种用途,或者它们是否只是具有不同包的相同库。但是,我正在寻找一种方法来删除其中一个。
com.google.appengine.api.datastore
- 专门设计用于部署在 AppEngine 上的应用程序。如果您稍后决定将您的应用程序部署到其他地方(例如 Compute Engine),则 API 将不起作用。
com.google.cloud.datastore
- 是新的 API,它允许您从部署在任何地方的应用程序访问数据存储区,而不仅仅是 AppEngine。
com.google.appengine.api.datastore
- 有一些其他的没有的附加功能(至少现在还没有)。例如,OR
数据存储查询中的条件,与其他 AppEngine 服务(如 MemCache、全文搜索等)集成的能力。
我正在开发一个应用引擎项目并使用 Google 数据存储存储我的数据。我使用的是不同的数据存储库,因为它们是示例中使用的库,但我发现我必须同时使用这两个库有点奇怪:
如果我查看文档进行查询,在这个例子中他们使用这个库来处理查询:
com.google.appengine.api.datastore
https://cloud.google.com/appengine/docs/java/datastore/retrieving-query-results
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(q); Entity result = pq.asSingleEntity();
然而,在这个例子中存储数据,他们使用
com.google.cloud.datastore
https://cloud.google.com/datastore/docs/concepts/entities
Entity task = Entity.builder(taskKey) .set("category", "Personal") .set("done", false) .set("priority", 4) .set("description", "Learn Cloud Datastore") .build();
现在我可以同时使用两者,但我想知道哪一个更适合哪种用途,或者它们是否只是具有不同包的相同库。但是,我正在寻找一种方法来删除其中一个。
com.google.appengine.api.datastore
- 专门设计用于部署在 AppEngine 上的应用程序。如果您稍后决定将您的应用程序部署到其他地方(例如 Compute Engine),则 API 将不起作用。
com.google.cloud.datastore
- 是新的 API,它允许您从部署在任何地方的应用程序访问数据存储区,而不仅仅是 AppEngine。
com.google.appengine.api.datastore
- 有一些其他的没有的附加功能(至少现在还没有)。例如,OR
数据存储查询中的条件,与其他 AppEngine 服务(如 MemCache、全文搜索等)集成的能力。