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.
-
Install Infinispan Server.
-
Open your Infinispan Server configuration for editing.
-
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.
Configure your cache with Protobuf encoding if you want to view cache entries in the Infinispan Console (
encoding media-type="application/x-protostream"
). -
Add an
endpoint
declaration to your configuration. -
Add the
resp-connector
element and specify the name of the cache to use with the RESP connector with thecache
attribute.You can use only one cache with the RESP endpoint.
-
Declare the security realm to use with the RESP endpoint with the
security-realm
attribute, if required. -
Ensure that the endpoint declaration also adds a Hot Rod and REST connector.
-
Save the changes to your configuration.
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
<endpoints>
<endpoint socket-binding="default" security-realm="default">
<resp-connector cache="mycache" />
<hotrod-connector />
<rest-connector/>
</endpoint>
</endpoints>
{
"server": {
"endpoints": {
"endpoint": {
"socket-binding": "default",
"security-realm": "default",
"resp-connector": {
"cache": "mycache"
},
"hotrod-connector": {},
"rest-connector": {}
}
}
}
}
server:
endpoints:
endpoint:
socketBinding: "default"
securityRealm: "default"
respConnector:
cache: "mycache"
hotrodConnector: ~
restConnector: ~