Hi All
I'm still trying to wrap my head around the Cayenne caching system,
(maybe Friday afternoon isn't doing me any good)
I have a test case as follows:
public void testBasicSelectQueryWithoutDaoWithCache() {
initCache();
assertEquals(0, getDataContext().getQueryCache().size());
SelectQuery q = new SelectQuery(Admin.class);
q.setCacheGroups("testGroup");
q.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
List<Admin> result = getDataContext().performQuery(q);
assertEquals(2, result.size());
SelectQuery q2 = new SelectQuery(Admin.class);
List<Admin> result2 = getDataContext().performQuery(q2);
assertEquals(2, result2.size());
assertEquals(1, getDataContext().getQueryCache().size());
}
private void initCache() {
DataContext context = (DataContext) getDataContext();
DataDomain domain = context.getParentDataDomain();
domain.setQueryCacheFactory(new OSQueryCacheFactory());
domain.setSharedCacheEnabled(true);
this.osCache = true;
}
I would expect that the the second query q2 would not execute any SQL
however the QueryLogger logs the second select statement.
Also the assert on the query cache size fails the it appears the size
is zero rather than 1 as I would have expected.
If I change the second call to performQuery to query q (List<Admin>
result2 = getDataContext().performQuery(q);) then in the log I get
DEBUG [AbstractConcurrentReadCache.java:694] => get called (key=Admin)
but the cache size in the last Assert is still 0 ???
I've read through the docs a few times and I can not see what I am doing wrong.
Thank you
Gary
This archive was generated by hypermail 2.0.0 : Fri May 28 2010 - 06:21:26 UTC