GAE caching objectifies queries

I have a simple question

the objectivity documentation says "Only get (), put () and delete () interact with the cache. query () is not cached" http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify# Global_Cache .

what I'm wondering is - if you have one root object (I didn't use @Parent due to all the scalability issues it seems to be), all other objects have a key and you run a query like

ofy.query(ChildEntity.class).filter("rootEntity", rootEntity).list()

      

is it completely bypassing the cache?

If so, there is an efficient way to cache queries on conditions - or for that matter, you can cache a query with a parent where you would need to make the actual query to the ancestor, like the following

Key<Parent> rootKey = ObjectifyService.factory().getKey(root)
ofy.query(ChildEntity.class).ancestor(rootKey)

      

thank


as in one of the comments below i added edit

sample dao (ignore check method - it just does quantity and quantity check):

this is the sample that finds all the methods inside the delegate called from the DAO that the factory ServiceLocator request uses

public List<EquipmentCheckin> findAll(Subject subject, Objectify ofy, Event event) {
  final Business business = (Business) subject.getSession().getAttribute(BUSINESS_ATTRIBUTE);
  final List<EquipmentCheckin> checkins = ofy.query(EquipmentCheckin.class).filter(BUSINESS_ATTRIBUTE, business)
    .filter(EVENT_CONDITION, event).list();
  return validate(ofy, checkins);
}

      

now when this is done I found that in my AbstractDAO the following method is actually being called.

/**
* 
* @param id
* @return
*/
public T find(Long id) {
  System.out.println("finding " + clazz.getSimpleName() + " id = " + id);
  return ObjectifyService.begin().find(clazz, id);
}

      

+3


source to share


1 answer


Yes, all queries bypass Objectify's integrated memcache and retrieve results directly from the datastore. The data warehouse provides a (increasingly sophisticated) query mechanism that understands how to return results; determining whether the cache is invalid for query results is nearly impossible from the client side.



On the other hand, Objectify4 offers a hybrid request cache whereby requests are automatically converted to a key-only request, followed by a batch get. The key request still requires a data store, but any entity instances are fetched from (and filled in in the pass) memcache. This can save you money.

+6


source







All Articles