I've set breakpoints inside DefaultServer.java on in the function with the following signature:
private <T> T findIdCheckPersistenceContextAndCache(Transaction transaction, BeanDescriptor<T> beanDescriptor, SpiQuery<T> query)
2 breakpoints:
1) inside the check for an active transaction ( if (t != null) )
This breakpoint is never hit in my test, which makes sense since Ebean.find(Entity.class,id); is never called inside a transaction.
2) Inside the If statement:
Object cachedBean = beanDescriptor.cacheGetBean(query.getId(), vanilla, query.isReadOnly());
if (cachedBean != null) {
//break here
If I'm understanding the code correctly, the second bit is looking in the bean cache.
This break point isn't hit at all when just loading the page in question (each load is triggering a call to Ebean.find(Entity.class, id). However after triggering an action which saves the entity via Ebean.save(entity), each GET request to load the page does hit this breakpoint which implies (i think) its coming out of the bean cache.
Stepping into the preceding check:
if (!beanDescriptor.calculateUseCache(query.isUseBeanCache())) {
// not using bean cache
return null;
}
seems to indicate the bean cache is active. query.isUseBeanCache() is null but tracing this through to BeanDescriptor.java there is a beanCache setup which causes the check to pass.
So I guess it appears the L2 bean cache is enabled. I guess my question then becomes why? The docs indicate that it is off by default unless @CacheStrategy is set on the entity. I've searched my entire code base for usages of the work 'cache' with no hits related.
Is there something that would enable it automatically?
Cheers,
Mark