Apache Ignite: Distributed In-Memory Key-Value Store

DZone 's Guide to

Apache Ignite: Distributed In-Memory Key-Value Store

A starter's guide to the benefits of Apache Ignite and executing SQL queries.

· Database Zone ·
Free Resource

Apache Ignite

For systems where low latency is critical, there is nothing better than caching the data in memory in a distributed cluster. While storing data in memory provides fast data access, distributing it on a cluster of nodes increases application performance and scalability. And Apache Ignite helps you achieve exactly that.

Ignite data grid is a distributed in-memory key-value store. It can also be viewed as a partitioned hash map that enables caching data in-memory over multiple server nodes. You can store as much data as you want, in memory, by adding new nodes to the Ignite cluster at anytime. As a key-value store, Ignite data grid supports:

Partitioning and Replication

Ignite can be configured to either replicate or partition the data in memory. In a replicated cache, data is fully replicated on all the nodes in the cluster. In a partitioned cache, the data is evenly split and distributed cluster-wide so that each node contains only a subset of the total data.



Ignite allows you to store multiple backup copies of cached data within your cluster. Configuring backup prevents data loss in case of a node crash. You can configure as many backups as the total number of nodes in the cluster.


Ignite supports atomic and transactional modes for cache operations. In atomic mode, multiple atomic operations are performed individually. In transactional mode, multiple cache operations are grouped and executed in a single transaction. The transactional mode in Ignite is fully ACID compliant, and data always remains consistent, regardless of node failures. 

Data Locality

Ignite determines data locality using a pluggable hashing algorithm. Every client can determine which node a key belongs to by plugging it into a hashing function. This eliminates the need for any special mapping servers or name nodes that can potentially be a single point of failure. 

SQL Queries

To query the Ignite cache, you can simply use standard SQL syntax (ANSI-99). Ignite lets you use any SQL functions, aggregations, or groupings. It also supports distributed SQL joins. Here is an example of how to execute an SQL query in Ignite: 

// ‘Select’ query to concatenate the first and last name of all persons
// and associate them with organization names.
SqlFieldsQuery sql = new SqlFieldsQuery(
  "select concat(p.firstName, ' ', p.lastName), o.name " +
  "from Person p, Organization o " +
  "where p.orgId = o.id");

// Execute the query on Ignite cache and print the result.
try (QueryCursor<List<?>> cursor = cache.query(sql)) {
  System.out.println("Persons and Organizations: " + cursor.getAll());


Here is an example of some basic cache operations in Ignite:

// Store keys in cache.
cache.put("Hello", "World");

// Retrieve values from cache.
String val = cache.get("Hello");

// Replace-if-exists operation.
boolean success = cache.replace("Hello", "Again");

// Remove-if-exists operation.
success = cache.remove("Hello");


If you prefer to watch a running example, here is a short screencast.


Apache Ignite stores data in distributed caches across multiple nodes providing fast data access. Caches can be configured to store data in either partitioned or replicated manner. Ignite clusters are resilient to node failures and data on Ignite nodes is guaranteed to be consistent as long as the cluster is alive. Ignite is easy to setup and use which helps developers get started in no time.

For more information, documentation, and screencasts, visit the Apache Ignite website.

ignite ,cache ,jcache ,key-value ,key-value stores ,database ,fault tolerance ,scalability

Published at DZone with permission of Prachi Garg . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}