Clients

Hazelcast Python Client

Hazelcast enables you to use an unparalleled range of massively scalable data structures with your Python applications. You can:

  • Use the Hazelcast Near Cache feature to store frequently read data in your Python process. This provides faster read speeds than traditional caches such as Redis or Memcached.
  • Access all of the Hazelcast data structures plus distributed queues, topics, and more with the Hazelcast IMDG Python Client.
  • Support JSON or serialized objects.

Quick Start + Download

Quick Start

You can install Hazelcast Python Client via:
$ pip install hazelcast-python-client

Downloads
Version Downloads Documentation
Hazelcast IMDG Python Client 5.2.0 (latest)
03/31/2023
Hazelcast IMDG Python Client 5.1
04/29/2022
Hazelcast IMDG Python Client 5.0.1
10/19/2021
Hazelcast IMDG Python Client 4.2.2
10/19/2021

For all downloads please see the Download Archives

Previous Releases

Code Samples

import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get the Distributed Map from Cluster.
my_map = client.get_map("my-distributed-map").blocking()
# Standard Put and Get
my_map.put("key", "value")
my_map.get("key")
# Concurrent Map methods, optimistic updating
my_map.put_if_absent("somekey", "somevalue")
my_map.replace_if_same("key", "value", "newvalue")
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get a Blocking Queue called "my-distributed-queue"
queue = client.get_queue("my-distributed-queue").blocking()
# Offer a String into the Distributed Queue
queue.offer("item")
# Poll the Distributed Queue and return the String
item = queue.poll()
# Timed blocking Operations
queue.offer("anotheritem", 0.5)
another_item = queue.poll(5)
# Indefinitely blocking Operations
queue.put("yetanotheritem")
print(queue.take())
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast


def print_on_message(topic_message):
    print("Got message", topic_message.message)


# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get a Topic called "my-distributed-topic"
topic = client.get_topic("my-distributed-topic").blocking()
# Add a Listener to the Topic
topic.add_listener(print_on_message)
# Publish a message to the Topic
topic.publish("Hello to distributed world")
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get the Distributed List from Cluster.
my_list = client.get_list("my-distributed-list").blocking()
# Add element to the list
my_list.add("item1")
my_list.add("item2")

# Remove the first element
print("Removed:", my_list.remove_at(0))
# There is only one element left
print("Current size is", my_list.size())
# Clear the list
my_list.clear()
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get a Replicated Map called "my-replicated-map"
rmap = client.get_replicated_map("my-replicated-map").blocking()
# Put and Get a value from the Replicated Map
replaced_value = rmap.put("key", "value")
# key/value replicated to all members
print("replaced value =", replaced_value)
# Will be None as its first update
value = rmap.get("key")
# the value is retrieved from a random member in the cluster
print("value for key =", value)
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get the Distributed Set from Cluster.
my_set = client.get_set("my-distributed-set").blocking()
# Add items to the set with duplicates
my_set.add("item1")
my_set.add("item1")
my_set.add("item2")
my_set.add("item2")
my_set.add("item2")
my_set.add("item3")
# Get the items. Note that there are no duplicates.
for item in my_set.get_all():
    print(item)
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
# Get the Distributed MultiMap from Cluster.
multi_map = client.get_multi_map("my-distributed-multimap").blocking()
# Put values in the map against the same key
multi_map.put("my-key", "value1")
multi_map.put("my-key", "value2")
multi_map.put("my-key", "value3")
# Print out all the values for associated with key called "my-key"
values = multi_map.get("my-key")
print(values)
# remove specific key/value pair
multi_map.remove("my-key", "value2")
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github
import hazelcast

# Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
client = hazelcast.HazelcastClient()
rb = client.get_ringbuffer("rb").blocking()
# add two items into ring buffer
rb.add(100)
rb.add(200)
# we start from the oldest item.
# if you want to start from the next item, call rb.tailSequence()+1
sequence = rb.head_sequence()
print(rb.read_one(sequence))
sequence += 1
print(rb.read_one(sequence))
# Shutdown this Hazelcast Client
client.shutdown()
Get this code sample on Github

Features Implemented for this Client

Data Structures
Python Client

Map

Queue

Set

List

MultiMap

Replicated Map

Ring Buffer

Topic

Reliable Topic

JCache

N/A

Cardinality Estimator

Concurrency Primitives
Python Client

Lock

Condition

Semaphore

AtomicLong

AtomicReference

ID Generator

CountDownLatch

CRDT PN Counter

Flake ID Generator

Distributed Processing
Python Client

Distributed Executor Service

Event Listeners

Sub-Listener Interfaces for Map Listener

Entry Processor

Transactions
Python Client

TxnMap

TxnMultiMap

TxnQueue

TxnList

TxnSet

Query
Python Client

SQL

Query (Predicates)

Paging Predicates

Partition Predicates

Built-in Predicates

Continuous Query Caching

Listener with Predicate

Projections

Fast Aggregations

Near Cache
Python Client

Near Cache Support

HD Memory

N/A

Preload Cache from Last Used

Eventual Consistency Control

Configuration
Python Client

Declarative Configuration (XML/JSON/YAML)

Programmatic Configuration

Client Configuration Import

Fail Fast on Invalid Configuration

Security
Python Client

SSL Support

XA Transactions

Mutual Authentication

Authorization

Custom Authentication Modules

Management Center
Python Client

Management Center Integration / Awareness

Client Near Cache Stats

Client Runtime Stats

Client Operating System Stats

Cloud
Python Client

Hazelcast Viridian services

Kubernetes

AWS

Azure

Google Cloud Platform

Pivotal Cloud Foundry

Docker

Apache jclouds

Consul

etcd

Eureka

Heroku

Zookeeper

Infrastructure
Python Client

Open Client Protocol

Smart Client

Unisocket Client

Lifecycle Service

HeartBeat

Backup Acknowledgement to Client

Diagnostics

Serialization
Python Client

Compact Serialization (Beta)

DataSerializable

N/A

IdentifiedDataSerializable

Portable Serialization

Custom Serialization

Global Serialization

Client Connectivity
Python Client

Connection Strategy

Connection Retry

Blue/Green Deployments and Disaster Recovery