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 template is an instance of the CacheConfiguration class that can be registered in the cluster via the Ignite.addCacheConfiguration(...) method. Basically, you can create a CacheConfiguration with some name and register it. Once this happens, you can use this configuration as a template where the template's name corresponds to the name of the registered configuration.

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


Lets create a cache template and register it in the cluster:

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"> 
          <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 the template name to create another cache with the same configuration:

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";