Apache Geode CHANGELOG

Managing Region Attributes

Use region attributes to fine-tune the region configuration provided by the region shortcut settings.

All region attributes have default settings, so you only need to use region attributes to set the ones you want to override. See <region-attributes>.

Define Region Attributes

Create region attributes using any of these methods:

  • Declarations inside the cache.xml <region> element:

       <region name="exampleRegion" refid="REPLICATE">
          <region-attributes statistics-enabled="true">
              <expiration-attributes timeout="10" action="destroy"/>

    When the cache.xml is loaded at startup, declared region attributes are automatically created and applied to the region.

  • RegionFactory API set* method calls:

    // Creating a partitioned region using the RegionFactory
    RegionFactory rf = cache.createRegionFactory(RegionShortcut.PARTITION);
    rf.addCacheListener(new LoggingCacheListener());
    custRegion = rf.create("customer");
    // Creating a partitioned region using the RegionFactory, with attribute modifications
    RegionFactory rf = 
    rf.setPartitionResolver(new CustomerOrderResolver());
    rf.addCacheListener(new LoggingCacheListener());
    custRegion = rf.create("customer");
    // Creating a client with a Pool Specification Using ClientRegionFactory
    ClientRegionFactory<String,String> cRegionFactory = 
    Region<String, String> region = 
  • By issuing the gfsh create region command.

Modify Region Attributes

You can modify a region’s event handlers and expiration and eviction attributes after the region is created.

Note: Do not modify attributes for existing regions unless absolutely necessary. Creating the attributes you need at region creation is more efficient.

Modify attributes in one of these ways:

  • By loading a cache.xml with modified region attribute specifications:

    <!-- Change the listener for exampleRegion
        <region name="exampleRegion">
          <region-attributes statistics-enabled="true">
  • Using the AttributesMutator API:

    1. Retrieve the AttributesMutator from the region
    2. Call the mutator set methods to modify attributes:
    currRegion = cache.getRegion("root");
    AttributesMutator mutator = this.currRegion.getAttributesMutator();
    mutator.addCacheListener(new LoggingCacheListener()); 
  • By issuing the gfsh alter region command. See alter region.