Infinispan Server includes an endpoint that implements the RESP3 protocol and allows you to interact with remote caches using Redis clients.

1. Using the RESP endpoint

Infinispan Server includes an experimental module that implements the RESP3 protocol. The RESP endpoint allows Redis clients to connect to one or several Infinispan-backed RESP servers and perform cache operations.

1.1. Enabling the RESP endpoint

Add the resp-connector to Infinispan Server configuration to enable the RESP endpoint. You can enable the RESP endpoint with:

  • Standalone Infinispan Server deployments, exactly like standalone Redis, where each server instance runs independently of each other.

  • Clustered Infinispan Server deployments, where server instances replicate or distribute data between each other. Clustered deployments provides clients with failover capabilities.

Prerequisites
  • Install Infinispan Server.

Procedure
  1. Open your Infinispan Server configuration for editing.

  2. Add cache configuration to the cache-container section if required.

    Cache configuration cannot enable capabilities that violate the RESP protocol. For example, specifying expiration values in a cache for the RESP endpoint results in a fatal error at startup.

    If the cache is defined you must define the key encoding as application/octet-stream.

    Configure your cache value encoding with Protobuf encoding if you want to view cache entries in the Infinispan Console (value media-type="application/x-protostream").

  3. Add an endpoint declaration to your configuration.

  4. Add the resp-connector element and specify the name of the cache to use with the RESP connector with the cache attribute.

    You can use only one cache with the RESP endpoint.

  5. Declare the security realm to use with the RESP endpoint with the security-realm attribute, if required.

  6. Ensure that the endpoint declaration also adds a Hot Rod and REST connector.

  7. Save the changes to your configuration.

Verification

When you start Infinispan Server check for the following log message:

[org.infinispan.SERVER] ISPN080018: Started connector Resp (internal)

You can now connect to the RESP endpoint with a Redis client. For example, with the Redis CLI you can do the following to add an entry to the cache:

redis-cli -p 11222 --user username --pass password
127.0.0.1:11222> SET k v
OK
127.0.0.1:11222> GET k
"v"
127.0.0.1:11222> quit
RESP endpoint configuration
XML
<endpoints>
  <endpoint socket-binding="default" security-realm="default">
    <resp-connector cache="mycache" />
    <hotrod-connector />
    <rest-connector/>
  </endpoint>
</endpoints>
JSON
{
  "server": {
    "endpoints": {
      "endpoint": {
        "socket-binding": "default",
        "security-realm": "default",
        "resp-connector": {
          "cache": "mycache"
        },
        "hotrod-connector": {},
        "rest-connector": {}
      }
    }
  }
}
YAML
server:
  endpoints:
    endpoint:
      socketBinding: "default"
      securityRealm: "default"
      respConnector:
        cache: "mycache"
      hotrodConnector: ~
      restConnector: ~

1.2. Redis commands

The Infinispan RESP endpoint implements the following Redis commands:

Command Notes

APPEND

AUTH

BLPOP

BRPOP

CLIENT GETNAME

CLIENT ID

CLIENT INFO

CLIENT LIST

CLIENT SETINFO

CLIENT SETNAME

COMMAND

CLUSTER NODES

This commands includes all required fields, some are set to 0 as they do not apply to Infinispan.

CLUSTER SHARDS

CLUSTER SLOTS

DBSIZE

DECR

DECRBY

DEL

DISCARD

ECHO

EXEC

See MULTI.

EXISTS

EXPIRE

EXPIREAT

EXPIRETIME

FLUSHALL

Behaves like FLUSHDB since Infinispan does not support multiple Redis databases yet.

FLUSHDB

GET

GETDEL

GETEX

GETRANGE

GETSET

Deprecated. Use the SET command with the appropriate flags.

HDEL

HELLO

HEXISTS

HGET

HINCRBY

HINCRBYFLOAT

HKEYS

HLEN

HMGET

HMSET

HRANDFIELD

HSCAN

HSET

HSETNX

HSTRLEN

HVALS

INCR

INCRBY

INCRBYFLOAT

INFO

This implementation attempts to return all attributes that a real Redis server returns. However, in most cases, the values are set to 0, because they cannot be retrieved or don’t make any sense in Infinispan.

KEYS

LINDEX

LINSERT

Current implementation time complexity is O(N), where N is the size of the list.

LLEN

LCS

LMOVE

Current implementation is atomic for rotation (source and destination are the same list). For different lists there is relaxed consistency for concurrent operations or failures unless the resp cache is configured to used transactions.

LMPOP

LPOP

LPOS

LPUSH

LPUSHX

LRANGE

LREM

LSET

LTRIM

MEMORY-USAGE

This command will return the memory used by the key and the value. It doesn’t include the memory used by additional metadata associated with the entry.

MEMORY-STATS

This command will return the same fields as a real Redis server, but all values will be set to 0.

MGET

MODULE LIST

Always returns an empty list of modules.

MSET

MSETNX

MULTI

The current implementation has a relaxed isolation level. Redis offers serializable transactions, but Infinispan provides a read-uncommitted isolation.

PERSIST

PEXPIRE

PEXPIRETIME

PING

PSETEX

Deprecated. Utilize SET with the appropriate flags.

PSUBSCRIBE

PTTL

PUBLISH

PUNSUBSCRIBE

QUIT

RANDOMKEY

RPOP

RPOPLPUSH

RPUSH

RPUSHX

READONLY

READWRITE

RENAME

RENAMENX

RESET

SADD

SCARD

SCAN

Cursors are reaped in case they have not been used within a timeout (5 minutes)

SDIFF

SDIFFSTORE

SELECT

Always returns -ERR Select not supported in cluster mode

SET

SETEX

Deprecated. Use the SET command with the appropriate flags.

SETNX

Deprecated. Use the SET command with the appropriate flags.

SETRANGE

SINTER

SINTERCARD

SINTERSTORE

SISMEMBER

SORT

SORT_RO

SMEMBERS

SMOVE

SPOP

SRANDMEMBER

SSCAN

STRLEN

SUBSTR

Deprecated. Use the GETRANGE command.

SUBSCRIBE

SUNION

SUNIONSTORE

TIME

TTL

TYPE

UNSUBSCRIBE

UNWATCH

WATCH

ZADD

ZCARD

ZCOUNT

ZDIFF

ZDIFFSTORE

ZINCRBY

ZINTER

ZINTERCARD

ZINTERSTORE

ZLEXCOUNT

ZMPOP

ZPOPMAX

ZPOPMIN

ZUNION

ZUNIONSTORE

ZRANDMEMBER

ZRANGE

ZRANGEBYLEX

ZRANGEBYSCORE

ZREVRANGE

ZREVRANGEBYLEX

ZREVRANGEBYSCORE

ZRANGESTORE

ZREM

ZREMRANGEBYLEX

ZREMRANGEBYRANK

ZREMRANGEBYSCORE

ZSCAN

ZSCORE