Over a million developers have joined DZone.

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

Learn how API management supports better integration in Achieving Enterprise Agility with Microservices and API Management, brought to you in partnership with 3scale

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!

Unleash the power of your APIs with future-proof API management - Create your account and start your free trial today, brought to you in partnership with 3scale.

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

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}