[英]Is entity key in memcache the same as in datastore
When I set the key of a memcache entity like this 当我像这样设置memcache实体的键时
syncCache.put(entityKey, entity);
where 哪里
entityKey = entity.getKey();
entityKeyIdFromDataStore = entityKey.getId();
and afterwards I retrieve the entity stored in memcache and retrieve the key id 然后我检索存储在memcache中的实体并检索密钥ID
entity = (Entity) syncCache.get(entityKey);
entityKeyIdFromCache = entity.getKey().getId();
will entityKeyIdFromDataStore and entityKeyIdFromCache be the same then? 然后,entityKeyIdFromDataStore和entityKeyIdFromCache会相同吗?
Yes, it will be the same. 是的,会一样。 Note that you can use an ID instead of a key:
请注意,您可以使用ID代替密钥:
syncCache.put(entityKey.getId(), entity);
entity = (Entity) syncCache.get(entityKey.getId());
An ID is much shorter than a key. ID比密钥短得多。 This, of course, only works with entities that don't have parents, or if you store only one entity kind in Memcache.
当然,这仅适用于没有父母的实体,或者仅在Memcache中存储一种实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.