LATEST VERSION: 8.0.0 - CHANGELOG
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>
    </util:properties>
    
    <gfe:cache properties-ref="gemfire-props"/>
    
    <gfe:replicated-region id="Customer">
        <gfe:cache-listener>
        <bean 
         class="org.springframework.data.gemfire.examples.util.LoggingCacheListener"/>
        </gfe:cache-listener>
    </gfe:replicated-region>

...
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);

	 
	@SuppressWarnings("unchecked")
	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() + " " + 
			dave.getLastname());
		}
		
		Customer alicia = region.get(2L);
		if (alicia !=null) {
			log.debug("retrieved " + 
			alicia.getFirstname() + " " +
			alicia.getLastname());
			alicia.add(new Address("Keys Street","Alicia","UK"));
			region.put(alicia.getId(), alicia);
		}
	}

	
}

Additional Resources