Cayenne User Documentation
Caching and Fresh Data

## What Is Cached in Cayenne

Using multiple levels of caching in Cayenne allows to significantly improve performance, reducing the number of trips to the database. There are two things that Cayenne can cache - individual objects and query results (i.e. lists of objects). These two types are handled differently by Cayenne, as described below.

## Caching Persistent Objects

Individual objects are cached by Cayenne by default as they are fetched from the database or created by the user. Such caching is both a performance optimization mechanism and a way to ensure internal object uniquing. Users normally do not need to do anything special for this to work. Still there are a few parameters that can be configured

## Caching Query Results - Pluggable Cache

Out of the box Cayenne provides two implementations of the pluggable cache factory:

- `'org.apache.cayenne.cache.MapQueryCacheFactory'` is a default factory that uses an LRU map to store query results. LRU map ensures that cached results would not take up all available memory, but otherwise it has no cache expiration mechanism.

- `'org.apache.cayenne.cache.OSQueryCacheFactory'` is a factory that installs OpenSymphony OSCache as a cache provider for Cayenne queries. It allows to configure cache expiration policies and cross-VM synchronization via an `"oscache.properties"` that should be placed in the CLASSPATH.

## Cache Groups

## Refreshing the Data

### Sections

1. RefreshQuery

.
Copyright ©2001-2007 Apache Software Foundation