---
title: Geode Redis Adapter
---

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

**Note:** This feature is experimental and is subject to change in future releases of <%=vars.product_name_long%>.

The <%=vars.product_name%> Redis adapter allows <%=vars.product_name%> to function as a drop-in replacement for a Redis data store, letting Redis applications take advantage of <%=vars.product_name%>’s scaling capabilities without changing their client code. Redis clients connect to a <%=vars.product_name%> server in the same way they connect to a Redis server, using an IP address and a port number.

-   **[Using the Redis Adapter](#using-the-redis-adapter)**

-   **[How the Redis Adapter Works](#how-the-redis-adapter-works)**

-   **[Advantages of <%=vars.product_name%> over a Redis Server](#advantages-of-geode-over-redis)**

## <a id="using-the-redis-adapter" class="no-quick-link"></a>Using the Redis Adapter

To use the Redis Adapter, you will need three pieces of information:

1.  The port number through which clients will communicate
2.  The IP address of the host where the server is to reside
3.  A choice of which attributes you will use for a <%=vars.product_name%> partitioned region

The IP address and port number should be the same ones coded in the Redis clients.

In order to take advantage of <%=vars.product_name%>’s scaling capabilities, you should specify the <%=vars.product_name%> region as one of the types that use the PARTITION data policy. PARTITION is the default. Other possibilities include PARTITION\_REDUNDANT and PARTITION\_PERSISTENT. (See [“Region Shortcuts Quick Reference”](../reference/topics/region_shortcuts_table.html) for a complete list.)

To implement a <%=vars.product_name%> instance using the Redis Adapter:

1.  Install <%=vars.product_name%> on the system where the server is to reside.
2.  Use gfsh to start a <%=vars.product_name%> server, specifying the three configuration options described above:
    -   Use `--redis-port` to specify the port. This parameter is required -- the <%=vars.product_name%> server will listen on this port for Redis commands.
    -   Use `--redis-bind-address` to specify the IP address of the server host. This parameter is optional. If not specified, the default is determined from the /etc/hosts file.
    -   Use `--J=-Dgemfireredis.regiontype` to specify the region type. This parameter is optional. If not specified, regiontype is set to PARTITION.

For example:

``` pre
gfsh> start server --name=server1 --redis-bind-address=localhost \
 --redis-port=11211 --J=-Dgemfireredis.regiontype=PARTITION_PERSISTENT
```

Redis clients can then connect to the server at localhost:11211.

## <a id="how-the-redis-adapter-works" class="no-quick-link"></a>How the Redis Adapter Works

The <%=vars.product_name%> Redis Adapter supports all Redis data structures, including

-   String
-   List
-   Hash
-   Set
-   SortedSet
-   HyperLogLog

In <%=vars.product_name%> these data structures are implemented using partitioned regions. In most cases, <%=vars.product_name%> allocates one partitioned region for each data structure. For example, each Sorted Set is allocated its own partitioned region, in which the key is the user data and the value is the user-provided score, and entries are indexed by score. The two exceptions to this design are data types String and HyperLogLog. All Strings are allocated to a single partitioned region. Similarly, all HyperLogLogs are allocated to a single region. Regions use <%=vars.product_name%>’s OQL and indexes.

The <%=vars.product_name%> Redis Adapter supports all Redis commands for each of the Redis data structures. (See the Javadocs for the GemFireRedisServer class for a detailed list.) The <%=vars.product_name%> server’s responses to Redis commands are identical to those of a Redis server with the following exceptions, resulting from <%=vars.product_name%>’s more extensive partitioning model:

-   Any command that removes keys and returns a count of removed entries will return a count of how many entries have been removed from the local vm, rather than a total count of items removed across all members. However, all entries will be removed.
-   Any command that returns a count of newly set members has an unspecified return value. The command will work just as the Redis protocol states, but the count will not necessarily reflect the number set compared to the number overridden.
-   Transactions work just as they would on a Redis instance; they are local transactions. Transactions cannot be executed on data that is not local to the executing server, that is on a partitioned region in a different server instance, or that is on a persistent region that does not have transactions enabled. Also, you cannot watch or unwatch keys, as all keys within a <%=vars.product_name%> transaction are watched by default.

## <a id="advantages-of-geode-over-redis" class="no-quick-link"></a>Advantages of <%=vars.product_name%> over a Redis Server

<%=vars.product_name%>’s primary advantage is its **scalability**. While the Redis server is single threaded, <%=vars.product_name%> supports high concurrency. Many Redis clients can execute commands on the <%=vars.product_name%> server simultaneously.

<%=vars.product_name%> supports **stored procedures**, which can execute on the server and report results to the requesting client.

<%=vars.product_name%> architecture and management features help detect and resolve **network partitioning** problems without explicit management on the part of the Redis client.

<%=vars.product_name%> **WAN replication** allows the data store to expand horizontally, across physically distant sites, while maintaining data consistency.


