cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: How the cache works ?
Date Wed, 01 Aug 2007 17:03:55 GMT

On Aug 1, 2007, at 5:06 PM, Jean-Paul Le Fèvre wrote:

> Moreover I don't know if there is a way to configure the size of  
> the cache.

More on that.... IMO until 3.0 query cache (as opposed to individual  
object cache) was fairly immature. Users have very little control  
over its behavior. Some things were easy to fix (like the one I  
mentioned before), but others were not so simple.

In 3.0 caching mechanism is pluggable and I've personally pushed the  
envelope pretty far in customizing it in my own applications. What's  
missing (due to the early alpha status of 3.0) is good documentation  
and Modeler support.

What you can already do is this:

1. Configure Query Cache Policy

DataDomain domain = ..
domain.setQueryCacheFactory(new OSQueryCacheFactory());
// default is "domain.setQueryCacheFactory(new MapQueryCacheFactory());"
// and you can write your own as well..

OSQueryCacheFactory (based on OSCache as the name implies) allows you  
to configure cross-VM notifications, "group" expiration policies,  
cache size, and more.

2. Setup Queries

As I mentioned before, there is no need to assign the name to a query  
anymore. You still need to select a cache policy. And there's one  
more optional setting that makes a query manageable via OSCache - an  
array of arbitrary cache groups. Those are used to expire groups of  
query results in one shot, and generally allow to assign queries to a  
given OS Cache policy definition. E.g.:

SelectQquery query = ...
query.setCacheGroups(new String[] {"g1", "g5"});

View raw message