Skip to content

2. Configuration

Nikita Koksharov edited this page Jun 25, 2019 · 111 revisions

Contents:

2.1. Programmatic configuration

2.2. Declarative configuration

2.3. Common settings

2.4. Cluster mode

2.5. Replicated mode

2.6. Single instance mode

2.7. Sentinel mode

2.8. Master slave mode

2.9. Proxy mode

2.1. Programmatic configuration

Programmatic configuration performed by Config object instance. For example:

Config config = new Config();
config.setTransportMode(TransportMode.EPOLL);
config.useClusterServers()
       // use "rediss://" for SSL connection
      .addNodeAddress("redis://127.0.0.1:7181");

RedissonClient redisson = Redisson.create(config);

2.2. Declarative configuration

Redisson can also be configured in a declarative way by using a user supplied text file in either JSON or YAML format, or alternatively, it can be configured using Spring Redisson namespace in a Spring XML file.

2.2.1 JSON/YAML file based configuration

Redisson configuration could be stored in JSON or YAML format.
Use Config.fromJSON method to read configuration stored in JSON format:

Config config = Config.fromJSON(new File("config-file.json"));  
RedissonClient redisson = Redisson.create(config);

Use Config.toJSON method to write configuration in JSON format:

Config config = new Config();
// ... many settings are set here
String jsonFormat = config.toJSON();

Use config.fromYAML method to read configuration stored in YAML format:

Config config = Config.fromYAML(new File("config-file.yaml"));  
RedissonClient redisson = Redisson.create(config);

Use config.toYAML method to write configuration in YAML format:

Config config = new Config();
// ... many settings are set here
String jsonFormat = config.toYAML();

Environmental variables should be wrapped in ${...}. Example:

singleServerConfig:
  address: "redis://127.0.0.1:${REDIS_PORT}"

Default values complies with shell format. Example:

singleServerConfig:
  address: "redis://127.0.0.1:${REDIS_PORT:-6379}"

2.2.2 Spring XML namespace configuration

Redisson has provided a namespace configuration method for Spring framework.

A Redisson instance can be configured like this:

<redisson:client>
    <redisson:single-server ... />
    <!-- or -->
    <redisson:master-slave-servers ... />
    <!-- or -->
    <redisson:sentinel-servers ... />
    <!-- or -->
    <redisson:cluster-servers ... />
    <!-- or -->
    <redisson:replicated-servers ... />
</redisson:client>

For more Spring Redisson namespace usage details please head to [Integration with frameworks Spring Framework section](./14.-Integration with frameworks/#141-spring-framework). For all the options available to each connection types please follow their descriptions below.

2.3. Common settings

Follow settings belong to org.redisson.Config object and common for all modes:

codec

Default value: org.redisson.codec.FstCodec

Redis data codec. Used during read and write Redis data. Several implementations are available:

Codec class name Description
org.redisson.codec.FstCodec FST up to 10x faster than JDK Serialization codec. Default codec
org.redisson.codec.JsonJacksonCodec Jackson JSON codec.
org.redisson.codec.AvroJacksonCodec Avro binary json codec
org.redisson.codec.SmileJacksonCodec Smile binary json codec
org.redisson.codec.CborJacksonCodec CBOR binary json codec
org.redisson.codec.MsgPackJacksonCodec MsgPack binary json codec
org.redisson.codec.IonJacksonCodec Amazon Ion codec
org.redisson.codec.KryoCodec Kryo binary codec
org.redisson.codec.SerializationCodec JDK Serialization codec
org.redisson.codec.LZ4Codec LZ4 compression codec
org.redisson.codec.SnappyCodec Netty's implementation of Snappy compression codec
org.redisson.codec.SnappyCodecV2 Snappy compression codec based on snappy-java project
org.redisson.client.codec.JsonJacksonMapCodec Map codec. Used to avoid storing class type in json and solve problem with byte[] serialization.
org.redisson.client.codec.StringCodec String codec
org.redisson.client.codec.LongCodec Long codec
org.redisson.client.codec.ByteArrayCodec Byte array codec
org.redisson.codec.CompositeCodec Used to mix different codecs as one
threads

Default value: 16

Threads amount shared across all listeners of RTopic object, invocation handlers of RRemoteService object and RExecutorService tasks.

nettyThreads

Default value: 32

Threads amount shared between all redis clients used by Redisson. Netty threads used in Redis response decoding and command sending.

executor

Use external ExecutorService which process all listeners of RTopic, RRemoteService invocation handlers and RExecutorService tasks.

eventLoopGroup

Use external EventLoopGroup. EventLoopGroup processes all Netty connection tied with Redis servers by own threads. Each Redisson client creates own EventLoopGroup by default. So if there are multiple Redisson instances in same JVM it would be useful to share one EventLoopGroup among them.

Only io.netty.channel.epoll.EpollEventLoopGroup, io.netty.channel.kqueue.KQueueEventLoopGroup and io.netty.channel.nio.NioEventLoopGroup are allowed for usage.

transportMode

Default value: TransportMode.NIO

Available values:
TransportMode.NIO,
TransportMode.EPOLL - requires netty-transport-native-epoll lib in classpath
TransportMode.KQUEUE - requires netty-transport-native-kqueue lib in classpath

lockWatchdogTimeout

Default value: 30000

Lock watchdog timeout in milliseconds. This parameter is only used if lock has been acquired without leaseTimeout parameter definition. Lock will be expired after lockWatchdogTimeout if watchdog didn't extend it to the next lockWatchdogTimeout time interval. This prevents against infinity locked locks due to Redisson client crush or any other reason when lock can't be released in proper way.

addressResolverGroupFactory

Default value: org.redisson.connection.DnsAddressResolverGroupFactory

Allows to specify customized implementation of DnsAddressResolverGroup.

Available implementations:

  • org.redisson.connection.DnsAddressResolverGroupFactory - uses default DNS servers list provided by OS.
  • org.redisson.connection.RoundRobinDnsAddressResolverGroupFactory - uses default DNS servers list provided by OS in round robin mode.
useScriptCache

Default value: false

Defines whether to use Lua-script cache on Redis side. Most Redisson methods are Lua-script based and this setting turned on could increase speed of such methods execution and save network traffic.

NOTE: readMode option is not taken into account for such calls as Redis slave redirects execution of cached Lua-script on Redis master node.

decodeInExecutor

Default value: false

Defines whether to decode data by codec in executor's threads or netty's threads. If decoding data process takes long time and netty thread is used then RedisTimeoutException could arise time to time.

keepPubSubOrder

Default value: true

Defines whether keep PubSub messages handling in arrival order or handle messages concurrently. This setting applied only for PubSub messages per channel.

performanceMode

Default value: HIGHER_THROUGHPUT

Defines command processing engine performance mode. Since all values are application specific (except NORMAL value) it's recommended to try all of them.

This setting is available only in Redisson PRO edition.

Available values:

  • HIGHER_THROUGHPUT - switches command processor engine to higher throughput mode
  • LOWER_LATENCY_AUTO - switches command processor engine to lower latency mode and detect optimal settings automatically
  • LOWER_LATENCY_MODE_2 - switches command processor engine to lower latency mode with predefined settings set #2
  • LOWER_LATENCY_MODE_1 - switches command processor engine to lower latency mode with predefined settings set #1
  • NORMAL - switches command processor engine to normal mode

2.4. Cluster mode

Cluster mode could be used with any hosting, but also supports AWS ElastiCache Cluster and Azure Redis Cache.

Programmatic config example:

Config config = new Config();
config.useClusterServers()
    .setScanInterval(2000) // cluster state scan interval in milliseconds
    // use "rediss://" for SSL connection
    .addNodeAddress("redis://127.0.0.1:7000", "redis://127.0.0.1:7001")
    .addNodeAddress("redis://127.0.0.1:7002");

RedissonClient redisson = Redisson.create(config);

2.4.1. Cluster settings

Documentation covers Redis server cluster configuration is here. Minimal cluster configuration requires to contain at least three master nodes. Cluster connection mode activated by follow line:
ClusterServersConfig clusterConfig = config.useClusterServers();

ClusterServersConfig settings listed below:

nodeAddresses

Add Redis cluster node address in host:port format. Multiple nodes could be added at once. At least one node from Redis Cluster should be specified, Redisson discovers automatically all others. Use rediss:// protocol for SSL connection.

scanInterval

Default value: 1000

Redis cluster scan interval in milliseconds.

slots

Default value: 231

Partitions amount used for data partitioning. Data partitioning supported by Set, Map, BitSet, Bloom filter, Spring Cache and Hibernate Cache structures.

This setting is available only in Redisson PRO edition.

readMode

Default value: SLAVE

Set node type used for read operation. Available values:
SLAVE - Read from slave nodes, uses MASTER if no SLAVES are available.
MASTER - Read from master node,
MASTER_SLAVE - Read from master and slave nodes

subscriptionMode

Default value: SLAVE

Set node type used for subscription operation. Available values:
SLAVE - Subscribe to slave nodes,
MASTER - Subscribe to master node,

loadBalancer

Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

subscriptionConnectionMinimumIdleSize

Default value: 1

Minimum idle connection pool size for subscription (pub/sub) channels. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap, RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy.

subscriptionConnectionPoolSize

Default value: 50

Maximum connection pool size for subscription (pub/sub) channels. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap, RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy

slaveConnectionMinimumIdleSize

Default value: 24

Redis 'slave' node minimum idle connection amount for each slave node

slaveConnectionPoolSize

Default value: 64

Redis 'slave' node maximum connection pool size for each slave node

masterConnectionMinimumIdleSize

Default value: 24

Redis 'master' node minimum idle connection amount for each slave node

masterConnectionPoolSize

Default value: 24

Redis 'master' node maximum connection pool size

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout

Default value: 10000

Timeout in milliseconds during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout in milliseconds. Starts to countdown when Redis command was succesfully sent.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval in milliseconds after which another one attempt to send Redis command will be executed.

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per subscribe connection limit. Used by RTopic, RPatternTopic, RLock, RSemaphore, RCountDownLatch, RClusteredLocalCachedMap, RClusteredLocalCachedMapCache, RLocalCachedMap, RLocalCachedMapCache objects and Hibernate READ_WRITE cache strategy.

clientName

Default value: null

Name of client connection.

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification during handshaking, which prevents man-in-the-middle attacks.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections. OPENSSL considered as faster implementation and requires netty-tcnative-boringssl-static to be added in classpath.

sslTruststore

Default value: null

Defines path to SSL truststore. It's stores certificates which is used to identify server side of SSL connection.

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore. It's stores private key and certificates corresponding to their public keys. Used if server side of SSL connection requires client authentication.

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

natMap

Default value: empty map

Defines NAT mapping. Address as a map key is replaced with mapped address as value.

2.4.2. Cluster JSON, YAML and Spring XML config format

Below is cluster configuration example in JSON format. All property names matches with ClusterServersConfig and Config object property names.

{
   "clusterServersConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "failedSlaveReconnectionInterval":3000,
      "failedSlaveCheckInterval":60000,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "loadBalancer":{
         "class":"org.redisson.connection.balancer.RoundRobinLoadBalancer"
      },
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "slaveConnectionMinimumIdleSize":24,
      "slaveConnectionPoolSize":64,
      "masterConnectionMinimumIdleSize":24,
      "masterConnectionPoolSize":64,
      "readMode":"SLAVE",
      "subscriptionMode":"SLAVE",
      "nodeAddresses":[
         "redis://127.0.0.1:7004",
         "redis://127.0.0.1:7001",
         "redis://127.0.0.1:7000"
      ],
      "scanInterval":1000,
      "pingConnectionInterval": 0,
      "keepAlive": false,
      "tcpNoDelay": false,
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is cluster configuration example in YAML format. All property names matches with ClusterServersConfig and Config object property names.

---
clusterServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  failedSlaveReconnectionInterval: 3000
  failedSlaveCheckInterval: 60000
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  slaveConnectionMinimumIdleSize: 24
  slaveConnectionPoolSize: 64
  masterConnectionMinimumIdleSize: 24
  masterConnectionPoolSize: 64
  readMode: "SLAVE"
  subscriptionMode: "SLAVE"
  nodeAddresses:
  - "redis://127.0.0.1:7004"
  - "redis://127.0.0.1:7001"
  - "redis://127.0.0.1:7000"
  scanInterval: 1000
  pingConnectionInterval: 0
  keepAlive: false
  tcpNoDelay: false
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

Below is cluster configuration example in Spring XML format. All attribute names matches with ClusterServersConfig and Config object property names using spring xml naming convention.

<redisson:client
    id="redisson"
    name="redisson1,redisson2"
    threads="0"
    netty-threads="0"
    codec-ref="myCodec" 
    transport-mode="NIO"
    reference-enabled="true"
    reference-codec-provider-ref="myCodecProvider"
    executor-ref="myExecutor"
    event-loop-group-ref="myEventLoopGroup"
>
    <!--
    You can't have both name attribute and qualifier element at
    the same time. 

    Both id attribute and name attribute can be used as qualifier
    candidates.
    -->
    <!--<qualifier value="redisson3"/>-->
    <redisson:cluster-servers
        idle-connection-timeout="10000"
        ping-timeout="1000"
        connect-timeout="10000"
        timeout="3000"
        retry-attempts="3"
        retry-interval="1500"
        reconnection-timeout="3000"
        failed-attempts="3"
        password="do_not_use_if_it_is_not_set"
        subscriptions-per-connection="5"
        client-name="none"
        load-balancer-ref="myLoadBalancer"
        subscription-connection-minimum-idle-size="1"
        subscription-connection-pool-size="50"
        slave-connection-minimum-idle-size="10"
        slave-connection-pool-size="64"
        master-connection-minimum-idle-size="10"
        master-connection-pool-size="64"
        read-mode="SLAVE"
        subscription-mode="SLAVE"
        scan-interval="1000"
    >
        <redisson:node-address value="redis://127.0.0.1:6379" />
        <redisson:node-address value="redis://127.0.0.1:6380" />
        <redisson:node-address value="redis://127.0.0.1:6381" />
    </redisson:cluster-servers>
</redisson:client>

<!-- minimal settings -->
<redisson:client>
    <redisson:cluster-servers>
        <redisson:node-address value="redis://127.0.0.1:6379" />
        <redisson:node-address value="redis://127.0.0.1:6380" />
        <redisson:node-address value="redis://127.0.0.1:6381" />
        ...
    </redisson:cluster-servers>
</redisson:client>

2.5. Replicated mode

Replicated mode could be used with any hosting, but also supports AWS ElastiCache and Azure Redis Cache.

Programmatic config example:

Config config = new Config();
config.useReplicatedServers()
    .setScanInterval(2000) // master node change scan interval
    // use "rediss://" for SSL connection
    .addNodeAddress("redis://127.0.0.1:7000", "redis://127.0.0.1:7001")
    .addNodeAddress("redis://127.0.0.1:7002");

RedissonClient redisson = Redisson.create(config);

2.5.1. Replicated settings

Replicated connection mode activated by follow line:

ReplicatedServersConfig replicatedConfig = config.useReplicatedServers();

Replicated ServersConfig settings listed below:

nodeAddresses

Add Redis node address in host:port format. Multiple nodes at once could be added. All nodes (master and slaves) should be provided. Use rediss:// protocol for SSL connection.

scanInterval

Default value: 1000

Replicated node scan interval in milliseconds.

loadBalancer

Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

dnsMonitoringInterval

Default value: 5000

Interval in milliseconds to check the endpoint's DNS. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable.

subscriptionConnectionMinimumIdleSize

Default value: 1

Redis 'slave' node minimum idle subscription (pub/sub) connection amount for each slave node

subscriptionConnectionPoolSize

Default value: 50

Redis 'slave' node maximum subscription (pub/sub) connection pool size for each slave node

slaveConnectionMinimumIdleSize

Default value: 24

Redis 'slave' node minimum idle connection amount for each slave node

slaveConnectionPoolSize

Default value: 64

Redis 'slave' node maximum connection pool size for each slave node

masterConnectionMinimumIdleSize

Default value: 24

Redis 'master' node minimum idle connection amount for each slave node

masterConnectionPoolSize

Default value: 64

Redis 'master' node maximum connection pool size

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

readMode

Default value: SLAVE

Set node type used for read operation. Available values:
SLAVE - Read from slave nodes, uses MASTER if no SLAVES are available.
MASTER - Read from master node,
MASTER_SLAVE - Read from master and slave nodes

subscriptionMode

Default value: MASTER

Set node type used for subscription operation. Available values:
SLAVE - Subscribe to slave nodes,
MASTER - Subscribe to master node,

connectTimeout

Default value: 10000

Timeout during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout. Starts to countdown when Redis command was succesfully sent. Value in milliseconds.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval after which another one attempt to send Redis command will be executed. Value in milliseconds.

failedSlaveReconnectionInterval

Default value: 3000

Interval of Redis Slave reconnection attempt when it was excluded from internal list of available servers. On each timeout event Redisson tries to connect to disconnected Redis server. Value in milliseconds.

failedSlaveCheckInterval

Default value: 60000

Redis Slave node failing to execute commands is excluded from the internal list of available nodes when the time interval from the moment of first Redis command execution failure on this server reaches defined value. Value in milliseconds.

database

Default value: 0

Database index used for Redis connection

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per Redis connection limit

clientName

Default value: null

Name of client connection

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore

Default value: null

Defines path to SSL truststore

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

2.5.2. Replicated JSON, YAML and Spring XML config format

Below is replicated servers configuration example in JSON format. All property names matches with ReplicatedServersConfig and Config object property names.

{
   "replicatedServersConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "failedSlaveReconnectionInterval":3000,
      "failedSlaveCheckInterval":60000,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "loadBalancer":{
         "class":"org.redisson.connection.balancer.RoundRobinLoadBalancer"
      },
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "slaveConnectionMinimumIdleSize":24,
      "slaveConnectionPoolSize":64,
      "masterConnectionMinimumIdleSize":24,
      "masterConnectionPoolSize":64,
      "readMode":"SLAVE",
      "subscriptionMode":"SLAVE",
      "nodeAddresses":[
         "redis://127.0.0.1:2812",
         "redis://127.0.0.1:2815",
         "redis://127.0.0.1:2813"
      ],
      "scanInterval":1000,
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is replicated configuration example in YAML format. All property names matches with ReplicatedServersConfig and Config object property names.

---
replicatedServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  failedSlaveReconnectionInterval: 3000
  failedSlaveCheckInterval: 60000
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  slaveConnectionMinimumIdleSize: 24
  slaveConnectionPoolSize: 64
  masterConnectionMinimumIdleSize: 24
  masterConnectionPoolSize: 64
  readMode: "SLAVE"
  subscriptionMode: "SLAVE"
  nodeAddresses:
  - "redis://127.0.0.1:2812"
  - "redis://127.0.0.1:2815"
  - "redis://127.0.0.1:2813"
  scanInterval: 1000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

Below is replicated servers configuration example in Spring XML format. All attribute names matches with ReplicatedServersConfig and Config object property names using spring xml naming convention.

<redisson:client
    id="redisson"
    name="redisson1,redisson2"
    threads="0"
    netty-threads="0"
    codec-ref="myCodec" 
    transport-mode="NIO"
    reference-enabled="true"
    reference-codec-provider-ref="myCodecProvider"
    executor-ref="myExecutor"
    event-loop-group-ref="myEventLoopGroup"
>
    <!--
    You can't have both name attribute and qualifier element at
    the same time. 

    Both id attribute and name attribute can be used as qualifier
    candidates.
    -->
    <!--<qualifier value="redisson3"/>-->
    <redisson:replicated-servers
        idle-connection-timeout="10000"
        ping-timeout="1000"
        connect-timeout="10000"
        timeout="3000"
        retry-attempts="3"
        retry-interval="1500"
        reconnection-timeout="3000"
        failed-attempts="3"
        password="do_not_use_if_it_is_not_set"
        subscriptions-per-connection="5"
        client-name="none"
        load-balancer-ref="myLoadBalancer"
        subscription-connection-minimum-idle-size="1"
        subscription-connection-pool-size="50"
        slave-connection-minimum-idle-size="10"
        slave-connection-pool-size="64"
        master-connection-minimum-idle-size="10"
        master-connection-pool-size="64"
        read-mode="SLAVE"
        subscription-mode="SLAVE"
        scan-interval="1000"
        database="0"
    >
        <redisson:node-address value="redis://127.0.0.1:6379" />
        <redisson:node-address value="redis://127.0.0.1:6380" />
        <redisson:node-address value="redis://127.0.0.1:6381" />
    </redisson:replicated-servers>
</redisson:client>

<!-- minimal settings -->
<redisson:client>
    <redisson:replicated-servers>
        <redisson:node-address value="redis://127.0.0.1:6379" />
        <redisson:node-address value="redis://127.0.0.1:6380" />
        <redisson:node-address value="redis://127.0.0.1:6381" />
        ...
    </redisson:replicated-servers>
</redisson:client>

2.6. Single instance mode

Programmatic config example:

// connects to 127.0.0.1:6379 by default
RedissonClient redisson = Redisson.create();

Config config = new Config();
config.useSingleServer().setAddress("redis://myredisserver:6379");
RedissonClient redisson = Redisson.create(config);

2.6.1. Single instance settings

Documentation covers Redis single server configuration is here. Multiple IP bindings for single hostname supported in Proxy mode

Single server connection mode activated by follow line:
SingleServerConfig singleConfig = config.useSingleServer();

SingleServerConfig settings listed below:

address

Redis server address in host:port format. Use rediss:// protocol for SSL connection.

subscriptionConnectionMinimumIdleSize

Default value: 1

Minimum idle Redis subscription connection amount.

subscriptionConnectionPoolSize

Default value: 50

Redis subscription connection maximum pool size.

connectionMinimumIdleSize

Default value: 24

Minimum idle Redis connection amount.

connectionPoolSize

Default value: 64

Redis connection maximum pool size.

dnsMonitoringInterval

Default value: 5000

DNS change monitoring interval. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable. Multiple IP bindings for single hostname supported in Proxy mode.

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout

Default value: 10000

Timeout during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout. Starts to countdown when Redis command was succesfully sent. Value in milliseconds.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval after which another one attempt to send Redis command will be executed. Value in milliseconds.

database

Default value: 0

Database index used for Redis connection

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per Redis connection limit

clientName

Default value: null

Name of client connection

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore

Default value: null

Defines path to SSL truststore

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

2.6.2. Single instance JSON, YAML and Spring XML config format

Below is single instance configuration example in JSON format. All property names matches with SingleServerConfig and Config object property names.

{
   "singleServerConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "address": "redis://127.0.0.1:6379",
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "connectionMinimumIdleSize":24,
      "connectionPoolSize":64,
      "database":0,
      "dnsMonitoringInterval":5000
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is single instance configuration example in YAML format. All property names matches with SingleServerConfig and Config object property names.

---
singleServerConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  address: "redis://127.0.0.1:6379"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  connectionMinimumIdleSize: 24
  connectionPoolSize: 64
  database: 0
  dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

Below is single instance configuration example in Spring XML format. All attribute names matches with SingleServerConfig and Config object property names using spring xml naming convention.

<redisson:client
    id="redisson"
    name="redisson1,redisson2"
    threads="0"
    netty-threads="0"
    codec-ref="myCodec" 
    transport-mode="NIO"
    reference-enabled="true"
    reference-codec-provider-ref="myCodecProvider"
    executor-ref="myExecutor"
    event-loop-group-ref="myEventLoopGroup"
>
    <!--
    You can't have both name attribute and qualifier element at
    the same time. 
    
    Both id attribute and name attribute can be used as qualifier
    candidates.
    -->
    <!--<qualifier value="redisson3"/>-->
    <redisson:single-server
        idle-connection-timeout="10000"
        ping-timeout="1000"
        connect-timeout="10000"
        timeout="3000"
        retry-attempts="3"
        retry-interval="1500"
        reconnection-timeout="3000"
        failed-attempts="3"
        password="do_not_use_if_it_is_not_set"
        subscriptions-per-connection="5"
        client-name="none"            
        address="redis://127.0.0.1:6379"
        subscription-connection-minimum-idle-size="1"
        subscription-connection-pool-size="50"
        connection-minimum-idle-size="10"
        connection-pool-size="64"
        database="0"
        dns-monitoring="false"
        dns-monitoring-interval="5000"
    />            
</redisson:client>

<!-- minimal settings -->
<!-- address defaults to 127.0.0.1:6379 -->
<redisson:client>
    <redisson:single-server/>
</redisson:client>

2.7. Sentinel mode

Programmatic config example:

Config config = new Config();
config.useSentinelServers()
    .setMasterName("mymaster")
    .addSentinelAddress("redis://127.0.0.1:26389", "redis://127.0.0.1:26379")
    .addSentinelAddress("redis://127.0.0.1:26319");

RedissonClient redisson = Redisson.create(config);

2.7.1. Sentinel settings

Documentation covers Redis server sentinel configuration is here. Sentinel connection mode activated by follow line:
SentinelServersConfig sentinelConfig = config.useSentinelServers();

SentinelServersConfig settings listed below:

dnsMonitoringInterval

Default value: 5000

Interval in milliseconds to check the endpoint's DNS. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable.

masterName

Master server name used by Redis Sentinel servers and master change monitoring task.

addSentinelAddress

Add Redis Sentinel node address in host:port format. Multiple nodes at once could be added.

readMode

Default value: SLAVE

Set node type used for read operation. Available values:
SLAVE - Read from slave nodes, uses MASTER if no SLAVES are available.
MASTER - Read from master node,
MASTER_SLAVE - Read from master and slave nodes

subscriptionMode

Default value: SLAVE

Set node type used for subscription operation. Available values:
SLAVE - Subscribe to slave nodes,
MASTER - Subscribe to master node,

loadBalancer

Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

subscriptionConnectionMinimumIdleSize

Default value: 1

Redis 'slave' node minimum idle subscription (pub/sub) connection amount for each slave node

subscriptionConnectionPoolSize

Default value: 50

Redis 'slave' node maximum subscription (pub/sub) connection pool size for each slave node

slaveConnectionMinimumIdleSize

Default value: 24

Redis 'slave' node minimum idle connection amount for each slave node

slaveConnectionPoolSize

Default value: 64

Redis 'slave' node maximum connection pool size for each slave node

masterConnectionMinimumIdleSize

Default value: 24

Redis 'master' node minimum idle connection amount for each slave node

masterConnectionPoolSize

Default value: 64

Redis 'master' node maximum connection pool size

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout

Default value: 10000

Timeout during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout. Starts to countdown when Redis command was succesfully sent. Value in milliseconds.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval after which another one attempt to send Redis command will be executed. Value in milliseconds.

failedSlaveReconnectionInterval

Default value: 3000

Interval of Redis Slave reconnection attempt when it was excluded from internal list of available servers. On each timeout event Redisson tries to connect to disconnected Redis server. Value in milliseconds.

failedSlaveCheckInterval

Default value: 60000

Redis Slave node failing to execute commands is excluded from the internal list of available nodes when the time interval from the moment of first Redis command execution failure on this server reaches defined value. Value in milliseconds.

database

Default value: 0

Database index used for Redis connection

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per Redis connection limit

clientName

Default value: null

Name of client connection

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore

Default value: null

Defines path to SSL truststore

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

2.7.2. Sentinel JSON, YAML and Spring XML config format

Below is sentinel configuration example in JSON format. All property names matches with SentinelServersConfig and Config object property names.

{
   "sentinelServersConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "failedSlaveReconnectionInterval":3000,
      "failedSlaveCheckInterval":60000,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "loadBalancer":{
         "class":"org.redisson.connection.balancer.RoundRobinLoadBalancer"
      },
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "slaveConnectionMinimumIdleSize":24,
      "slaveConnectionPoolSize":64,
      "masterConnectionMinimumIdleSize":24,
      "masterConnectionPoolSize":64,
      "readMode":"SLAVE",
      "subscriptionMode":"SLAVE",
      "sentinelAddresses":[
         "redis://127.0.0.1:26379",
         "redis://127.0.0.1:26389"
      ],
      "masterName":"mymaster",
      "database":0
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is sentinel configuration example in YAML format. All property names matches with SentinelServersConfig and Config object property names.

---
sentinelServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  failedSlaveReconnectionInterval: 3000
  failedSlaveCheckInterval: 60000
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  slaveConnectionMinimumIdleSize: 24
  slaveConnectionPoolSize: 64
  masterConnectionMinimumIdleSize: 24
  masterConnectionPoolSize: 64
  readMode: "SLAVE"
  subscriptionMode: "SLAVE"
  sentinelAddresses:
  - "redis://127.0.0.1:26379"
  - "redis://127.0.0.1:26389"
  masterName: "mymaster"
  database: 0
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

Below is sentinel configuration example in Spring XML format. All attribute names matches with SentinelServersConfig and Config object property names using spring xml naming convention.

<redisson:client
    id="redisson"
    name="redisson1,redisson2"
    threads="0"
    netty-threads="0"
    codec-ref="myCodec" 
    transport-mode="NIO"
    reference-enabled="true"
    reference-codec-provider-ref="myCodecProvider"
    executor-ref="myExecutor"
    event-loop-group-ref="myEventLoopGroup"
>
    <!--
    You can't have both name attribute and qualifier element at
    the same time. 

    Both id attribute and name attribute can be used as qualifier
    candidates.
    -->
    <!--<qualifier value="redisson3"/>-->
    <redisson:sentinel-servers
        idle-connection-timeout="10000"
        ping-timeout="1000"
        connect-timeout="10000"
        timeout="3000"
        retry-attempts="3"
        retry-interval="1500"
        reconnection-timeout="3000"
        failed-attempts="3"
        password="do_not_use_if_it_is_not_set"
        subscriptions-per-connection="5"
        client-name="none"
        load-balancer-ref="myLoadBalancer"
        subscription-connection-minimum-idle-size="1"
        subscription-connection-pool-size="50"
        slave-connection-minimum-idle-size="10"
        slave-connection-pool-size="64"
        master-connection-minimum-idle-size="10"
        master-connection-pool-size="64"
        read-mode="SLAVE"
        subscription-mode="SLAVE"
        master-name="myMaster"
        database="0"
    >
        <redisson:sentinel-address value="redis://127.0.0.1:26379" />
        <redisson:sentinel-address value="redis://127.0.0.1:26380" />
    </redisson:sentinel-servers>
</redisson:client>

<!-- minimal settings -->
<redisson:client>
    <redisson:sentinel-servers master-name="myMaster">
        <redisson:sentinel-address value="redis://127.0.0.1:26379" />
        <redisson:sentinel-address value="redis://127.0.0.1:26380" />
        ....
    </redisson:sentinel-servers>
</redisson:client>

2.8. Master slave mode

Programmatic config example:

Config config = new Config();
config.useMasterSlaveServers()
    // use "rediss://" for SSL connection
    .setMasterAddress("redis://127.0.0.1:6379")
    .addSlaveAddress("redis://127.0.0.1:6389", "redis://127.0.0.1:6332", "redis://127.0.0.1:6419")
    .addSlaveAddress("redis://127.0.0.1:6399");

RedissonClient redisson = Redisson.create(config);

2.8.1. Master slave settings

Documentation covers Redis server master/slave configuration is here. Master slave connection mode activated by follow line:
MasterSlaveServersConfig masterSlaveConfig = config.useMasterSlaveServers();

MasterSlaveServersConfig settings listed below:

dnsMonitoringInterval

Default value: 5000

Interval in milliseconds to check the endpoint's DNS. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable.

masterAddress

Redis master node address in host:port format. Use rediss:// protocol for SSL connection.

addSlaveAddress

Add Redis slave node address in host:port format. Multiple nodes at once could be added. Use rediss:// protocol for SSL connection.

readMode

Default value: SLAVE

Set node type used for read operation. Available values:
SLAVE - Read from slave nodes, uses MASTER if no SLAVES are available.
MASTER - Read from master node,
MASTER_SLAVE - Read from master and slave nodes

subscriptionMode

Default value: SLAVE

Set node type used for subscription operation. Available values:
SLAVE - Subscribe to slave nodes,
MASTER - Subscribe to master node,

loadBalancer

Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

subscriptionConnectionMinimumIdleSize

Default value: 1

Redis 'slave' node minimum idle subscription (pub/sub) connection amount for each slave node

subscriptionConnectionPoolSize

Default value: 50

Redis 'slave' node maximum subscription (pub/sub) connection pool size for each slave node

slaveConnectionMinimumIdleSize

Default value: 24

Redis 'slave' node minimum idle connection amount for each slave node

slaveConnectionPoolSize

Default value: 64

Redis 'slave' node maximum connection pool size for each slave node

masterConnectionMinimumIdleSize

Default value: 24

Redis 'master' node minimum idle connection amount for each slave node

masterConnectionPoolSize

Default value: 64

Redis 'master' node maximum connection pool size

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout

Default value: 10000

Timeout during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout. Starts to countdown when Redis command was succesfully sent. Value in milliseconds.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval after which another one attempt to send Redis command will be executed. Value in milliseconds.

failedSlaveReconnectionInterval

Default value: 3000

Interval of Redis Slave reconnection attempt when it was excluded from internal list of available servers. On each timeout event Redisson tries to connect to disconnected Redis server. Value in milliseconds.

failedSlaveCheckInterval

Default value: 60000

Redis Slave node failing to execute commands is excluded from the internal list of available nodes when the time interval from the moment of first Redis command execution failure on this server reaches defined value. Value in milliseconds.

database

Default value: 0

Database index used for Redis connection

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per Redis connection limit

clientName

Default value: null

Name of client connection

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore

Default value: null

Defines path to SSL truststore

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

2.8.2. Master slave JSON, YAML and Spring XML config format

Below is master slave configuration example in JSON format. All property names matches with MasterSlaveServersConfig and Config object property names.

{
   "masterSlaveServersConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "failedSlaveReconnectionInterval":3000,
      "failedSlaveCheckInterval":60000,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "loadBalancer":{
         "class":"org.redisson.connection.balancer.RoundRobinLoadBalancer"
      },
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "slaveConnectionMinimumIdleSize":24,
      "slaveConnectionPoolSize":64,
      "masterConnectionMinimumIdleSize":24,
      "masterConnectionPoolSize":64,
      "readMode":"SLAVE",
      "subscriptionMode":"SLAVE",
      "slaveAddresses":[
         "redis://127.0.0.1:6381",
         "redis://127.0.0.1:6380"
      ],
      "masterAddress": "redis://127.0.0.1:6379"
      "database":0
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is master slave configuration example in YAML format. All property names matches with MasterSlaveServersConfig and Config object property names.

---
masterSlaveServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  failedSlaveReconnectionInterval: 3000
  failedSlaveCheckInterval: 60000
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  slaveConnectionMinimumIdleSize: 24
  slaveConnectionPoolSize: 64
  masterConnectionMinimumIdleSize: 24
  masterConnectionPoolSize: 64
  readMode: "SLAVE"
  subscriptionMode: "SLAVE"
  slaveAddresses:
  - "redis://127.0.0.1:6381"
  - "redis://127.0.0.1:6380"
  masterAddress: "redis://127.0.0.1:6379"
  database: 0
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

Below is master slave configuration example in Spring XML format. All attribute names matches with MasterSlaveServersConfig and Config object property names using spring xml naming convention.

<redisson:client
    id="redisson"
    name="redisson1,redisson2"
    threads="0"
    netty-threads="0"
    codec-ref="myCodec" 
    transport-mode="NIO"
    reference-enabled="true"
    reference-codec-provider-ref="myCodecProvider"
    executor-ref="myExecutor"
    event-loop-group-ref="myEventLoopGroup"
>
    <!--
    You can't have both name attribute and qualifier element at
    the same time. 
    
    Both id attribute and name attribute can be used as qualifier
    candidates.
    -->
    <!--<qualifier value="redisson3"/>-->
    <redisson:master-slave-servers
        idle-connection-timeout="10000"
        ping-timeout="1000"
        connect-timeout="10000"
        timeout="3000"
        retry-attempts="3"
        retry-interval="1500"
        reconnection-timeout="3000"
        failed-attempts="3"
        password="do_not_use_if_it_is_not_set"
        subscriptions-per-connection="5"
        client-name="none"
        load-balancer-ref="myLoadBalancer"
        subscription-connection-minimum-idle-size="1"
        subscription-connection-pool-size="50"
        slave-connection-minimum-idle-size="10"
        slave-connection-pool-size="64"
        master-connection-minimum-idle-size="10"
        master-connection-pool-size="64"
        read-mode="SLAVE"
        subscription-mode="SLAVE"
        master-address="redis://127.0.0.1:6379"
        database="0"
    >
        <redisson:slave-address value="redis://127.0.0.1:6380" />
        <redisson:slave-address value="redis://127.0.0.1:6381" />
    </redisson:master-slave-servers>
</redisson:client>

<!-- minimal settings -->
<redisson:client>
    <redisson:master-slave-servers master-address="redis://127.0.0.1:6379">
        <redisson:slave-address value="redis://127.0.0.1:6380" />
        <redisson:slave-address value="redis://127.0.0.1:6381" />
        ...
    </redisson:master-slave-servers>
</redisson:client>

2.9. Proxy mode

Proxy mode supports multiple mirrors of Redis and fully compatible with RLEC Multiple Active Proxy feature. If single hostname is defined and DNS monitoring is enabled then all resolved ips are considered as proxy nodes and used by load balancer.

This feature available only in Redisson PRO edition.

Programmatic config example:

Config config = new Config();
config.useProxyServers().addAddress("redis://myredisserver:6379");
RedissonClient redisson = Redisson.create(config);

2.9.1. Proxy mode settings

Proxy servers connection mode activated by follow line:
ProxyServersConfig proxyConfig = config.useProxyServers();

ProxyServersConfig settings listed below:

addresses

Redis proxy servers addresses in host:port format. If single hostname is defined and DNS monitoring is enabled then all resolved ips are considered as proxy nodes and used by load balancer. Use rediss:// protocol for SSL connection.

subscriptionConnectionMinimumIdleSize

Default value: 1

Minimum idle Redis subscription connection amount.

subscriptionConnectionPoolSize

Default value: 50

Redis subscription connection maximum pool size.

connectionMinimumIdleSize

Default value: 24

Minimum idle Redis connection amount.

connectionPoolSize

Default value: 64

Redis connection maximum pool size.

dnsMonitoringInterval

Default value: 5000

DNS change monitoring interval. Applications must ensure the JVM DNS cache TTL is low enough to support this. Set -1 to disable.

idleConnectionTimeout

Default value: 10000

If pooled connection not used for a timeout time and current connections amount bigger than minimum idle connections pool size, then it will closed and removed from pool. Value in milliseconds.

connectTimeout

Default value: 10000

Timeout during connecting to any Redis server.

timeout

Default value: 3000

Redis server response timeout. Starts to countdown when Redis command was succesfully sent. Value in milliseconds.

retryAttempts

Default value: 3

Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. But if it sent succesfully then timeout will be started.

retryInterval

Default value: 1500

Time interval after which another one attempt to send Redis command will be executed. Value in milliseconds.

database

Default value: 0

Database index used for Redis connection

password

Default value: null

Password for Redis server authentication.

subscriptionsPerConnection

Default value: 5

Subscriptions per Redis connection limit

clientName

Default value: null

Name of client connection

sslEnableEndpointIdentification

Default value: true

Enables SSL endpoint identification.

sslProvider

Default value: JDK

Defines SSL provider (JDK or OPENSSL) used to handle SSL connections.

sslTruststore

Default value: null

Defines path to SSL truststore

sslTruststorePassword

Default value: null

Defines password for SSL truststore

sslKeystore

Default value: null

Defines path to SSL keystore

sslKeystorePassword

Default value: null

Defines password for SSL keystore

pingConnectionInterval

Default value: 0

Defines PING command sending interval per connection to Redis. Set 0 to disable.

keepAlive

Default value: false

Enables TCP keepAlive for connection.

tcpNoDelay

Default value: false

Enables TCP noDelay for connection.

loadBalancer

Default value: org.redisson.connection.balancer.RoundRobinLoadBalancer

Сonnection load balancer for multiple Redis servers. Available implementations:
org.redisson.connection.balancer.WeightedRoundRobinBalancer
org.redisson.connection.balancer.RoundRobinLoadBalancer
org.redisson.connection.balancer.RandomLoadBalancer

2.9.2. Proxy mode JSON and YAML config format

Below is proxy mode configuration example in JSON format. All property names matches with ProxyServersConfig and Config object property names.

{
   "proxyServersConfig":{
      "idleConnectionTimeout":10000,
      "connectTimeout":10000,
      "timeout":3000,
      "retryAttempts":3,
      "retryInterval":1500,
      "password":null,
      "subscriptionsPerConnection":5,
      "clientName":null,
      "addresses": "redis://127.0.0.1:6379",
      "subscriptionConnectionMinimumIdleSize":1,
      "subscriptionConnectionPoolSize":50,
      "connectionMinimumIdleSize":24,
      "connectionPoolSize":64,
      "database":0,
      "dnsMonitoringInterval":5000,
      "loadBalancer":{"class":"org.redisson.connection.balancer.RoundRobinLoadBalancer"}
   },
   "threads":16,
   "nettyThreads":32,
   "codec":{
      "class":"org.redisson.codec.FstCodec"
   },
   "transportMode":"NIO"
}

Below is proxy mode configuration example in YAML format. All property names matches with ProxyServersConfig and Config object property names.

---
proxyServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  addresses: "redis://127.0.0.1:6379"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  connectionMinimumIdleSize: 24
  connectionPoolSize: 64
  database: 0
  dnsMonitoringInterval: 5000
  loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"
You can’t perform that action at this time.