Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

The new Gartner Critical Capabilities report explains how APIs and microservices enable digital leaders to deliver better B2B, open banking and mobile projects.

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"/>
    </bean>
</property>
</bean>

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')
1
>>> r.incr('p1')
2
>>> r.incrby('p2', 5)
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!

The new Gartner Critical Capabilities for Full Lifecycle API Management report shows how CA Technologies helps digital leaders with their B2B, open banking, and mobile initiatives. Get your copy from CA Technologies.

Topics:
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 }}