Over a million developers have joined DZone.

Enabling Access to Apache Ignite via Redis Protocol

DZone's Guide to

Enabling Access to Apache Ignite via Redis Protocol

The Apache Ignite versions have the ability to store and retrieve data in the grid using any Redis client. Let's make connections to an Ignite cluster and do Redis string operations.

· Integration Zone ·
Free Resource

How to Transform Your Business in the Digital Age: Learn how organizations are re-architecting their integration strategy with data-driven app integration for true digital transformation.

Starting from 1.8.0, Apache Ignite introduced Redis protocol support and implemented a set of commands. Now, one can store and retrieve data in the grid using any Redis client.
In this article, we will see how to make connections to an Ignite cluster and do some Redis string operations.

Currently, the scope of the supported commands is limited mostly to Redis string operations, but more commands are planned to be introduced in future.

Apache Ignite has very rich functionalities for handling data in the grid using Java, C++, and C#, so let's choose a Python client and perform some string operations.

First of all, we need to have an Ignite cluster (or a single instance, if you have just started with the grid) running. By default, each Ignite node is listening for incoming requests on [host]:11211, but you can easily switch to Redis default port by overriding Ignite's ConnectorConfiguration as follows:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="connectorConfiguration">
    <bean class="org.apache.ignite.configuration.ConnectorConfiguration">
<property name="host" value="localhost"/>
<property name="port" value="6379"/>

To connect to the cluster, let's pick redis-py and have it properly installed as described here. After getting into Python interpreter, we are ready to connect:

>>> import redis
>>> r = redis.StrictRedis(host='localhost', port=6379, db=0)

As it was already mentioned above, the current Redis support scope is strings, as they are the most versatile and frequently used data type in Redis and have many commands. As a very simple demonstration, let's use INCR and INCRBY command to perform very simple counting — this can be page views, votes, likes, etc.

>>> r.incr('p1')
>>> r.incr('p1')
>>> r.incrby('p2', 5)

For the full list of supported commands, see this link.

That's all for now. Apache Ignite community welcomes your suggestions and contributions to improving Redis protocol support!

Build and deploy API integrations 7x faster. Try the Cloud Elements 100% RESTful platform for 30 days free. Access your trial here.

apache ignite ,redis ,data grid ,integration ,in-memory computing

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}