Cayenne supports local and distributed caching of fetched data. The design of the caching feature is discussed in the User Guide. When a new DataDomain is created, it uses default caching settings - data is cached within JVM, but no remote synchronization is performed. User can change these settings depending on the target application deployment strategy.

### No Cache Sharing Configuration

This type of configuration may result in somewhat faster commit operations, but is likely to lead to stale data when multiple users modify data in the same application. To disable any cache sharing uncheck "Use Shared Cache" checkbox.

### Local VM Cache Sharing Configuration

Default configuration for the new DataDomains. Ideal for applications that do not care about data being modified outside of the application. This configuration is acceptable for a lot of client-server and web applications.

### Cross-VM Cache Sharing Configuration

Configuration that allows to notify other applications about changes made by an application and to listen for such changes made by others. This type of configuration incurrs the most overhead, because it will constantly send and receive synchronization messages, but it is also the most powerful configuration. Cayenne currently supports the use of JMS and JavaGroups frameworks for synchronization, and also allows users to create their own transport mechanism.

| Cayenne distribution archive does not include JavaGroups or JMS libraries. Those must be downloaded and installed separately. However until deployment phase, Cayenne does not require those libraries to be installed.

To configure distributed cache sharing, check "Remote Change Notifications" checkbox, and click "Configure" button to select and configure the type of transport to use.

| Synchronization is only done between remote DataDomains with the same name. Note that for JavaGroups configuration, a combination of multicast address and port must be unique for each DataDomain name.

### Choosing JavaGroups over JMS

JavaGroups is the most portable and flexible mechanism. At the minimum, JMS setup requires a JMS server running, and subjects for each of the DataDomains to be configured. JavaGroups is peer-to-peer library that is embedded into applications. Default configuration provided by CayenneModeler will work out of the box, provided that IP multicast is enabled on the network.

The conclusion is that using JMS is probably most appropriate when deploying within J2EE containers that alreay support this service, while JavaGroups can be used in almost any environment.