Distribute Your Data

You’re an engineer who wants to distribute data for caching and sharing. Learn how to use Hazelcast data structures.

The quickest way to learn how to use Hazelcast IMDG is to start up a cluster and add some data to it. Check out the Getting Started Guide. Then we suggest you enroll in free training and take the Hazelcast IMDG Overview course. If you’re on the move, listen to a quick 10-minute podcast from one of the community engineers describing what Hazelcast is all about.

There are many caching technologies available, but we believe Hazelcast is the best, and here are seven reasons why.

Once you are ready to begin looking at the wider set of data structures, check out the extensive examples in all client languages. Links to each repository are below. For a quick start:

Here’s how you can add entries to a distributed map using a Java client

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

import java.util.Map;

public class FillMapMember {

    public static void main(String[] args) {
        HazelcastInstance hz = Hazelcast.newHazelcastInstance();
        Map<String, String> map = hz.getMap("map");
        map.put("1", "Tokyo");
        map.put("2", "Paris");
        map.put("3", "New York");
        System.out.println("Finished loading map");

Here’s a simple predicate query over some data in Java

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap;
import com.hazelcast.query.Predicates;

import java.util.Set;

public class SqlQueryMember {

    public static void main(String[] args) {
        HazelcastInstance hz = Hazelcast.newHazelcastInstance();
        IMap<String, Customer> map = hz.getMap("map");

        map.put("1", new Customer("peter", true, 36));
        map.put("2", new Customer("john", false, 40));
        map.put("3", new Customer("roger", true, 20));

        Set employees = (Set) map.values(Predicates.sql("active AND age < 30"));
        System.out.println("Employees: " + employees);


How about using a set in .NET?

using System;
using Hazelcast.Client;
using Hazelcast.Config;

namespace Hazelcast.Examples.Collections
    internal class SetExample
        private static void Run(string[] args)
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            var client = HazelcastClient.NewHazelcastClient(config);

            var set = client.GetSet("set-example");


            Console.WriteLine("Enumerator : " + string.Join(", ", set));

            Console.WriteLine("Contains: " + string.Join(", ", set.Contains("item2")));

            Console.WriteLine("Count: " + string.Join(", ", set.Count));


Make use of the CRDT PN counter in Python

import hazelcast
import logging

if __name__ == "__main__":

    client = hazelcast.HazelcastClient()

    pn_counter = client.get_pn_counter("pn-counter").blocking()

    print("Counter is initialized with {}".format(pn_counter.get()))

    for i in range(10):
        print("Added {} to the counter. Current value is {}".format(i, pn_counter.add_and_get(i)))

    print("Incremented the counter after getting the current value. "
          "Previous value is {}".format(pn_counter.get_and_increment()))

    print("Final value is {}".format(pn_counter.get()))

Generate a unique cluster-wide ID using Go

package main

import (


func main() {

	config := hazelcast.NewConfig()
	client, err := hazelcast.NewClientWithConfig(config)
	if err != nil {
	flakeIDGenerator, _ := client.GetFlakeIDGenerator("generator")
	id, _ := flakeIDGenerator.NewID()
	fmt.Printf("new id : %d", id)



There are many more examples for each language in their repository



Free Hazelcast Online Training Center

Whether you're interested in learning the basics of in-memory systems, or you're looking for advanced, real-world production examples and best practices, we've got you covered.