Configuring Regions

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

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 (from 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