blob: c95204d7e6501c13ced557b2097d18ae5005924c [file] [log] [blame]
<!--
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.
-->
<% set_title(product_name, "APIs Compatible with Redis") %>
Note: This feature is experimental and is subject to change in future releases of Apache Geode.
The <%=vars.product_name%> APIs compatible with Redis allow <%=vars.product_name%> to function as a drop-in replacement for a
highly-available 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 a hostname and a port number, with
optional password authentication.
<img src="../images_svg/geode_apis_compatible_with_redis.svg" class="image" />
## <a id="using-the-api" class="no-quick-link"></a>Using the <%=vars.product_name%> API compatible with Redis
The <%=vars.product_name%> cluster must have at least one server that is set up to handle the incoming Redis commands.
Use gfsh to start at least one server with a command of the form:
```pre
start server \
--name=<serverName> \
--locators=<locatorPort> \
--compatible-with-redis-port=<compatibleWithRedisPort> \
--compatible-with-redis-bind-address=<compatibleWithRedisBindAddress> \
--compatible-with-redis-password=<compatibleWithRedisPassword>
```
If any of the options `compatible-with-redis-bind-address`, `compatible-with-redis-password`, or `compatible-with-redis-port`
are included, a <%=vars.product_name%> server with APIs compatible with Redis will be started.
Replace `<serverName>` with the name of your server.
Replace `<locatorPort>` with your locator port.
Replace `<compatibleWithRedisPort>` with the port that the <%=vars.product_name%> server
listens on for Redis commands. The typical port used with a cluster compatible with Redis is 6379.
Replace `<compatibleWithRedisBindAddress>` with the address of the server host.
Replace `<compatibleWithWithRedisPassword>` with the password clients use to authenticate.
To confirm the server is listening, run:
``` pre
redis-cli -h <compatibleWithRedisBindAddress> -p <compatibleWithRedisPort> -a <compatibleWithRedisPassword> ping
```
Replace `<compatibleWithRedisBindAddress>`,`<compatibleWithRedisPort>`, and `<compatibleWithRedisPassword>` with the same values as the server.
If the server is functioning properly, you should see a response of `PONG`.
## <a id="supported-commands" class="no-quick-link"></a>Supported Redis Commands
The <%=vars.product_name%> APIs compatible with Redis currently support the following Redis commands.
<br/>
- APPEND <br/>
- AUTH <br/>
- DECR <br/>
- DECRBY <br/>
- DEL <br/>
- EXISTS <br/>
- EXPIRE <br/>
- EXPIREAT <br/>
- GET <br/>
- GETRANGE <br/>
- HDEL <br/>
- HEXISTS <br/>
- HGET <br/>
- HGETALL <br/>
- HINCRBY <br/>
- HINCRBYFLOAT <br/>
- HLEN <br/>
- HMGET <br/>
- HMSET <br/>
- HSCAN **[1]** <br/>
- HSET <br/>
- HSETNX <br/>
- HSTRLEN <br/>
- HVALS <br/>
- HKEYS <br/>
- INCR <br/>
- INCRBY <br/>
- INCRBYFLOAT <br/>
- INFO **[2]** <br/>
- KEYS <br/>
- MGET <br/>
- PERSIST <br/>
- PEXPIRE <br/>
- PEXPIREAT <br/>
- PING <br/>
- PSUBSCRIBE <br/>
- PTTL <br/>
- PUBLISH <br/>
- PUNSUBSCRIBE <br/>
- QUIT <br/>
- RENAME <br/>
- SADD <br/>
- SET <br/>
- SETNX <br/>
- SLOWLOG **[3]** <br/>
- SMEMBERS <br/>
- SREM <br/>
- STRLEN <br/>
- SUBSCRIBE <br/>
- TTL <br/>
- TYPE <br/>
- UNSUBSCRIBE <br/>
<br/>
Commands not listed above are **not implemented**.
<br/>
**NOTES:**
These commands are supported for Redis 5.
**[1]** Redis accepts 64-bit signed integers for the HSCAN cursor and COUNT parameters.
The Geode APIs compatible with Redis are limited to 32-bit integer values for these parameters.
**[2]** INFO is implemented for the sections and fields listed below:
- clients
- connected_clients
- blocked_clients (always returns 0)
- cluster
- cluster_enables (always returns 0)
- keyspace
- returns stats for db: 0
- memory
- maxmemory
- used_memory
- mem_fragmentation_ratio (always reports 1.00)
- persistence
- loading (always returns 0)
- rdb_changes_since_last_save (always returns 0)
- rdb_last_save_time (always returns 0)
- replication
- role
- connected_slaves (always returns 0)
- server
- redis_version
- redis_mode
- tcp_port
- uptime_in_seconds
- uptime_in_days
- stats
- total_commands_processed
- instantaneous_ops_per_sec
- total_net_input_bytes
- instantaneous_input_kbps
- total_connections_received
- keyspace_hits
- keyspace_misses
- evicted_keys (always returns 0)
- rejected_connections (always returns 0)
**[3]** SLOWLOG is implemented as a NoOp.
## <a id="advantages-over-redis" class="no-quick-link"></a>Advantages of <%=vars.product_name%> over Redis
<%=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%> cluster simultaneously.
<%=vars.product_name%>'s architecture and management features help detect and resolve **network partitioning** problems without explicit management on the part of the Redis client.
## <a id="expiration-accuracy" class="no-quick-link"></a>Expiration Accuracy
Keys are expired in two ways, actively and passively:
- With active expiration, expiration is evaluated whenever a key is accessed. If the key is due to expire, it is deleted. Active expiration is accurate to the millisecond.
- With passive expiration, keys are evaluated every second. If they are due to expire, they are deleted. Passive expiration is accurate to the second.
## <a id="high-availability-model" class="no-quick-link"></a>High Availability Model
Data is stored in a single partitioned region that has one redundant copy.
In practice this means that the cluster can tolerate the loss of a single server without the loss of
data.
## <a id="loss-of-connections" class="no-quick-link"></a>Loss of Connections
There are a number of events that might occur within the <%=vars.product_name%> cluster that can result
in the cluster closing the connection to the Redis client. Losing the connection to the cluster does not
imply that the server is no longer available.
When the connection is lost, the client should attempt to reconnect to the same server before
attempting to connect to another server.
The Redis client is responsible for knowing the addresses of all servers.
In the case of a connection failure, an invoked command may or may not complete.
The Redis client is responsible for deciding if the command should be retried.