Pivotal GemFire® v8.0

Configuring Regions

Configuring Regions

After you configure a cache, you can configure a region. There are four types of regions you can create.

  • replicated-region

    In a replicated region, each member holds all data defined for the region

  • partitioned-region

    In a partitioned region, portions of the data are held in each member. You configure a redundant copy of the data for failover scenarios.

  • local-region

    A local region does not share data with other member caches.

  • client-region

    Client regions connect to a cache server using a connection pool. See Configuring a Client/Server Architecture.

For more information on the types of regions you can create, see Region Types in the Pivotal GemFire User's Guide.

For example, the following Spring application context XML configuration (for the Consumer client in the basic/replicated example) creates a cache that uses the default id (gemfireCache) to create a replicated region named Customer. You can supply a valid bean name for the cache by specifying the name with the id attribute and then referencing the id with the cache-ref attribute of the region declaration.
    <util:properties id="gemfire-props">
        <prop key="log-level">warning</prop>
    <gfe:cache properties-ref="gemfire-props"/>
    <gfe:replicated-region id="Customer">

The following Java class populates a Customer object from the Customer region that is defined in the above XML declarations:
public class Consumer {
	 private static Log log = LogFactory.getLog(Consumer.class);

	public static void main(String args[]) throws IOException {
		ApplicationContext context = 
          new ClassPathXmlApplicationContext("consumer/cache-config.xml");
		Region<Long,Customer> region = context.getBean(Region.class);
		Customer dave = region.get(1L);
		if (dave != null) {
			log.debug("retrieved " + 
			dave.getFirstname() + " " + 
		Customer alicia = region.get(2L);
		if (alicia !=null) {
			log.debug("retrieved " + 
			alicia.getFirstname() + " " +
			alicia.add(new Address("Keys Street","Alicia","UK"));
			region.put(alicia.getId(), alicia);


Additional Resources