When I set the key of a memcache entity like this
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
entity = (Entity) syncCache.get(entityKey);
entityKeyIdFromCache = entity.getKey().getId();
will entityKeyIdFromDataStore and entityKeyIdFromCache be the same then?
Yes, it will be the same. Note that you can use an ID instead of a key:
syncCache.put(entityKey.getId(), entity);
entity = (Entity) syncCache.get(entityKey.getId());
An ID is much shorter than a key. This, of course, only works with entities that don't have parents, or if you store only one entity kind in Memcache.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.