Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.


GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.


Let's jump right in!


Documentation     Ask a Question     Download


Javadoc     Scaladoc     Examples

Cache Template


A cache template is an instance of the CacheConfiguration class that can be registered in the cluster via the Ignite.addCacheConfiguration(...) method and used later as a basis for creating new caches. A cache created from a template inherits all the properties of the template.

Cache templates are useful when you want to create a cache with the same configuration as an existing cache in the cluster. This allows you to create a cache without defining a long list of configuration parameters. Currently, templates in Ignite are supported for the CREATE TABLE and REST commands. When a template name is used, Ignite uses all the configurations mentioned in the template to instantiate the new cache.

Defining a Cache Template

To create a template, define a cache configuration and add it to the Ignite instance, as shown below. If you want do define a cache template in the XML configuration file, you must add an asterisk to the template's name. This is required to indicate that the configuration is a template and not an actual cache.

Ignite ignite = Ignition.start();

CacheConfiguration cfg = new CacheConfiguration("myCacheTemplate");
// Set required cache configuration properties.

// Register the cache template in Ignite.
<property name="cacheConfiguration"> 
       <bean id="cache-template-bean" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration"> 
         <!-- when you create a template via XML configuration, 
         you must add an asterisk to the name of the template -->
          <property name="name" value="myCacheTemplate*"/> 
          <property name="cacheMode" value="PARTITIONED" /> 
          <property name="backups" value="2" /> 
          <!-- Other cache configurations -->

Once the cache template is registered in the cluster, as shown in the code snippet above, you can use it to create another cache with the same configuration.

Creating a Cache Based On a Template

You can create a cache based on a template using the following commands.

Using the REST command


In the above command, replace host and port with actual values.

Using the CREATE TABLE command

  id int,
  city_id int,
  name varchar,
  age int, 
  company varchar,
  PRIMARY KEY (id, city_id)
) WITH "template=myCacheTemplate, key_type=PersonKey, value_type=MyPerson";

Updated about a year ago

Cache Template

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.