|Basic Configuration and Programming / Cache Management|
The cache provides in-memory storage and management for your data.
You organize your data in the cache into data regions, each with its own configurable behavior. You store your data into your regions in key/value pairs called data entries. The cache also provides features like transactions, data querying, disk storage management, and logging. See the Javadocs for com.gemstone.gemfire.cache.Cache.
You generally configure caches using a combination of XML declarations and API calls. GemFire loads and processes your XML declarations when you first create the cache.
GemFire has one cache type for managing server and peer caches and one for one for managing client caches. The cacheserver process automatically creates its server cache at startup. In your application process, the cache creation returns an instance of the server/peer or client cache. From that point on, you manage the cache through API calls in your application.
Your cache.xml must be formatted according to the dtd listed in the product dtd/cache7_0.dtd.
You use one format for peer and server caches and another for client caches.
<?xml version="1.0"?> <!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN" "http://www.gemstone.com/dtd/cache7_0.dtd"> <cache> ... </cache>
<?xml version="1.0"?> <!DOCTYPE client-cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN" "http://www.gemstone.com/dtd/cache7_0.dtd"> <client-cache> ... </client-cache>
For more information on the cache.xml file, see cache.xml.
Your system configuration and cache configuration are initialized when you start your member processes and create each member’s GemFire cache.
The steps in this section use gemfire.properties and cache.xml file examples, except where API is required. You can configure your distributed system properties and cache through the API as well, and you can use a combination of file configuration and API configuration.
The XML examples listings may not include the full cache.xml file listing. All of your declarative cache configuration must conform to the cache DTD listing in the product installation dtd/cache7_0.dtd.
Follow the instructions in the subtopics under Cache Management to customize your cache creation and closure for your application needs. You may need to combine more than one of the sets of instructions. For example, to create a client cache in a system with security, you would follow the instructions for creating and closing a client cache and for creating and closing a cache in a secure system.
To aid in the administration of cache data and speed the setup of new environments, you can export a snapshot of the entire cache (all regions) and then import the snapshot into a new cache. For example, you could take a snapshot of the production environment cache in order to import the cache's data into a testing environment.
For more details on exporting and importing snapshots of a cache, see Cache and Region Snapshots.