## Caching and Fresh Data

Caching is used by Cayenne to reduce database access and improve performance of your application. Sometimes caching automatically happens behind the scenes, and in other places the user must declare an intent to cache data. Configuring caching parameters beyond the provided reasonable defaults is an art of balancing performance with the need to see the fresh data.

The are two types of cache in Cayenne:

### Query Cache

This cache retains the results of a query in memory. When this cache is utilised by the second and successive queries, no further SELECT is performed on the database to determine which records match your query parameters.

### Object Cache

This cache stores the actual objects and not only eliminates the time required to fetch data from the database, but also the time required to instantiate that data into Java objects.

| As of Cayenne 3.0, two types of caches (individual object and query results) are separate from each other. Query cache can be extended and managed, while individual object cache has fewer configuration options - just max size and synchronization strategy. There are plans to reconcile both caches in the following releases.

### Sections

1. Individual object caching
2. Query result caching