Odd. MapQueryCacheFactory supports 'removeGroup' method (although it is not very efficient compared to say OSQueryCacheFactory). Can you possibly run this in debugger to check the state of the cache?

Andrus



On May 25, 2010, at 3:47 PM, Bob Schellink wrote:

Hi all,

I'm trying to add Cayenne caching for a web project I'm working on. A new DataContext is created for each request so I'm looking at adding a shared cache for entities that doesn't change often. However if one of those entities does get updated, I want to refresh the cache.

To start off with I'm trying to test with a small standalone application, following the
documentation here:

http://cayenne.apache.org/doc/query-result-caching.html

My test is fairly similar expect that I specify SHARED_CACHE instead of LOCAL_CACHE:

 SelectQuery query = new SelectQuery(Artist.class);
 query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
 query.setCacheGroups("artists");

I'm also using the default LRUMap.

From my test I can see that the query data is cached, but when I update the entity, invoke removeGroup and execute my query a second time, the database is not hit, so I assume the cached data
is returned.

Before going further I just wanted to check whether removeGroup does in fact work on shared caches?
Chances are that I've misconfigured the caching.

Kind regards

Bob


Reply via email to