库appengine.api.datastore和com.google.cloud.datastore有什么区别?

时间:2016-11-27 16:29:53

标签: java google-app-engine google-cloud-datastore datastore

我正在开发一个appengine项目并使用Google Datastore存储我的数据。我正在使用不同的数据存储库,因为它们是示例中使用的,但我觉得有点奇怪,我必须同时使用它们:

如果我查看文档进行查询,在本例中他们使用此库来处理查询:

  

的列举

https://cloud.google.com/appengine/docs/java/datastore/retrieving-query-results

  

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();   PreparedQuery pq = datastore.prepare(q);实体结果=   pq.asSingleEntity();

但是,在此示例中存储数据,他们使用

  

com.google.cloud.datastore

https://cloud.google.com/datastore/docs/concepts/entities

  

实体任务= Entity.builder(taskKey)       .set(“类别”,“个人”)       .set(“完成”,假)       .set(“priority”,4)       .set(“description”,“Learn Cloud Datastore”)       .build();

现在我可以使用两者但是我想知道哪一个更好用于哪种目的,或者它们是否只是具有不同包的相同库。但是,我正在寻找一种方法来删除其中一个。

1 个答案:

答案 0 :(得分:7)

chrome.runtime.getBackgroundPage(function(backgroundPageWindow) { // Do stuff here that requires access to the background page. // E.g. to access the function 'myFunction()' console.log("Calling myFunction() " + backgroundPageWindow.myFunction()); }); - 专门设计用于在AppEngine上部署的应用程序。如果您稍后决定在其他地方部署您的应用程序(例如计算引擎),则API无效。

chrome.extension.getBackgroundPage() - 是一种新的API,允许您从任何地方部署的应用程序访问数据存储,而不仅仅是AppEngine。

com.google.appengine.api.datastore - 有一些额外的功能,另一个没有(至少还没有)。例如,数据存储区查询中的com.google.cloud.datastore条件,能够与其他AppEngine服务集成,如MemCache,FullText搜索等。

相关问题