检查Google应用引擎数据存储中是否存在实体。 [英] Checking if Entity exists in google app engine datastore.

查看:161
本文介绍了检查Google应用引擎数据存储中是否存在实体。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查Google-app-engine数据存储中是否存在实体的最佳/最快方法是什么?现在我试图通过键获取实体,并检查get()是否返回错误。



我不知道获取实体的过程数据存储。有没有更快的方法来做这种检查? / code>已被弃用,以赞成App Engine GCS客户端。



您是否考虑过使用查询?猜测和检查不是一种可扩展的方式来查找数据存储中存在的实体。可以创建查询以从数据存储中检索符合指定条件的实体:

https://developers.google.com/appengine/docs/java/datastore/queries



编辑:

关键唯一查询怎么样?只有键的查询比返回完整实体的查询运行得更快。只返回键,使用Query.setKeysOnly()方法。

  new Query(Kind)。addFilter(Entity .KEY_RESERVED_PROPERTY,FilterOperator.EQUAL,key).setKeysOnly(); 

来源:[1]: http://groups.google.com/group/google-appengine-java/browse_thread/thread/b1d1bb69f0635d46/ 0e2ba938fad3a543?pli = 1


What is the best/fastest way to check if an Entity exists in a google-app-engine datastore? For now I'm trying to get the entity by key and checking if the get() returns an error.

I don't know the process of getting an Entity on the datastore. Is there a faster way for doing only this check?

解决方案

com.google.appengine.api has been deprecated in favor of the App Engine GCS client.

Have you considered using a query? Guess-and-check is not a scalable way to find out of an entity exists in a data store. A query can be created to retrieve entities from the datastore that meet a specified set of conditions:

https://developers.google.com/appengine/docs/java/datastore/queries

EDIT:

What about the key-only query? Key-only queries run faster than queries that return complete entities. To return only the keys, use the Query.setKeysOnly() method.

new Query("Kind").addFilter(Entity.KEY_RESERVED_PROPERTY, FilterOperator.EQUAL, key).setKeysOnly();

Source: [1]: http://groups.google.com/group/google-appengine-java/browse_thread/thread/b1d1bb69f0635d46/0e2ba938fad3a543?pli=1

这篇关于检查Google应用引擎数据存储中是否存在实体。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆