Cayenne User Documentation
Custom Query Cache Provider

By default Cayenne stores cached query results in an LRUMap (`'org.apache.cayenne.cache.MapQueryCacheFactory'`) and can also be configured to use OSCache (via `'org.apache.cayenne.cache.OSQueryCacheFactory'`). If none of these cache engines suit specific application needs, users can hook up their own.

Assuming you have some cache management library that you want to integrate with Cayenne, you need to implement a `'org.apache.cayenne.cache.QueryCacheFactory'` interface that creates an instance of `'org.apache.cayenne.cache.QueryCache'` that is a facade to your cache engine.

    class MyFactory implements QueryCacheFactory {
       public QueryCache getQueryCache(Map properties) {
          return new MyQueryCache(properties);
       }
    }

Custom factory can be set on the DataDomain:

    DataDomain domain = Configuration.getSharedConfiguration().getDomain();
    domain.setQueryCacheFactory(new MyFactory());

TODO: pending CAY-825 implementation, setting custom factory should be possible via CayenneModeler.

.
Copyright ©2001-2007 Apache Software Foundation