---
title:  Storing and Retrieving Region Shortcuts and Custom Named Region Attributes
---

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

Use these examples to get started with <%=vars.product_name%> region shortcuts.

<a id="region_shortcuts__section_D9E58754D2B0435FA2986DBBF3063D4C"></a>
<%=vars.product_name%> region shortcuts, in `org.apache.geode.cache.RegionShortcut` for peers and servers and `org.apache.geode.cache.client.ClientRegionShortcut` for clients, are available wherever you create a region in the `cache.xml` or through the API. Custom named attributes, stored by you, are available from the moment you store them on.

The region shortcuts are special <%=vars.product_name%> named region attributes, with identifying names. Create custom named region attributes by setting the attributes and storing them with a unique identifier in the region attribute `id`. Retrieve named attributes by providing the shortcut enum value or the name you assigned in the `id` to the region creation:

-   In the API, use the identifier in the region factory creation
-   In the `cache.xml`, use the identifier in the `<region>` or `<region-attribute>` `refid` setting. The `refid` is available in both elements for convenience

## <a id="region_shortcuts__section_8FCBCC4BDCDE4A85A27E5B9B70603F63" class="no-quick-link"></a>Examples

**Example \#1**

This example shows partitioned region creation in the `cache.xml`:

-   The first `region-attributes` declaration starts with the predefined `PARTITION_REDUNDANT` attributes, modifies the `local-max-memory` setting, and stores the resulting attributes in the custom-named `myPartition` attributes.
-   The region declarations use the new stored attributes, but each has its own interest policy, which is specified in the individual region creation.

    ``` pre
    <!-- Retrieving and storing attributes -->
    <region-attributes id="myPartition" refid="PARTITION_REDUNDANT">
        <partition-attributes local-max-memory="512"/>
    </region-attributes>

    <!-- Two partitioned regions, one colocated with the other -->

    <!-- Attributes are retrieved and applied in the first region -->
    <region name="PartitionedRegion1" refid="myPartition"/>

    <!-- Same stored attributes, modification for this region-->
    <region name="PartitionedRegion2" refid="myPartition">
        <region-attributes>
            <partition-attributes colocated-with="PartitionedRegion1" />
        </region-attributes>
    </region>
    ```

**Example \#2**

This example uses the `RegionFactory` API to create a region based on the predefined `PARTITION` region shortcut:

``` pre
final Region diskPortfolios = 
    new RegionFactory("PARTITION").create("Portfolios");
```

This example retrieves an attributes template and passes it to the region creation with a modified pool specification:

``` pre
ClientRegionFactory<String,String> regionFactory =         
    cache.createClientRegionFactory(PROXY);
Region<String, String> region = regionFactory
    .setPoolName("publisher")
    .create("DATA");
```
