Spring Boot

For Spring Boot usage please refer to Spring Boot article.

Micronaut

Redisson integrates with Micronaut framework.

Supports Micronaut 2.0.x - 4.x.x

Usage

1. Add redisson-micronaut dependency into your project:

Maven

  1. <dependency>
  2. <groupId>org.redisson</groupId>
  3. <!-- for Micronaut v2.0.x - v2.5.x -->
  4. <artifactId>redisson-micronaut-20</artifactId>
  5. <!-- for Micronaut v3.x.x -->
  6. <artifactId>redisson-micronaut-30</artifactId>
  7. <!-- for Micronaut v4.x.x -->
  8. <artifactId>redisson-micronaut-40</artifactId>
  9. <version>xVERSIONx</version>
  10. </dependency>

Gradle

  1. // for Micronaut v2.0.x - v2.5.x
  2. compile 'org.redisson:redisson-micronaut-20:xVERSIONx'
  3. // for Micronaut v3.x.x
  4. compile 'org.redisson:redisson-micronaut-30:xVERSIONx'
  5. // for Micronaut v4.x.x
  6. compile 'org.redisson:redisson-micronaut-40:xVERSIONx'

2. Add settings into application.yml file

Config structure is a Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode

NOTE: Setting names in camel case should be joined with hyphens (-).

Config example:

  1. redisson:
  2. single-server-config:
  3. address: "redis://127.0.0.1:6379"
  4. threads: 16
  5. netty-threads: 32

Upgrade to Redisson PRO with advanced features.

Cache

For Micronaut Cache usage please refer to Micronaut Cache article.

Session

Redisson provides Micronanut Session store implementation. Extra settings to HttpSessionConfiguration object:

Setting name Type Description
micronaut.session.http.redisson.enabled java.lang.Boolean Enables Session store
micronaut.session.http.redisson.key-prefix java.lang.Integer Defines string prefix applied to all objects stored in Redis.
micronaut.session.http.redisson.codec java.lang.Class Data codec applied to cache entries. Default is Kryo5Codec codec.
micronaut.session.http.redisson.update-mode java.lang.String Defines session attributes update mode.
WRITE_BEHIND - session changes stored asynchronously.
AFTER_REQUEST - session changes stored only on SessionStore#save(Session) method invocation. Default value.
micronaut.session.http.redisson.broadcastSessionUpdates java.lang.Boolean Defines broadcasting of session updates across all micronaut services.

Config example:

  1. micronaut:
  2. session:
  3. http:
  4. redisson:
  5. enabled: true
  6. update-mode: "WRITE_BEHIND"
  7. broadcast-session-updates: false

Quarkus

Redisson integrates with Quarkus framework and implements Quarkus Cache.

Supports Quarkus 1.6.x - 3.x.x

??? note “Native image with RemoteService. Click to expand” To use RemoteService in native image add dynamic-proxy.json and reflection-config.json files in quarkus.native.additional-build-args setting.

  1. ```
  2. -H:DynamicProxyConfigurationResources=dynamic-proxy.json,-H:ReflectionConfigurationFiles=reflection-config.json
  3. ```
  4. dynamic-proxy.json:
  5. ```
  6. [
  7. ["<Remote Service interface name>"]
  8. ]
  9. ```
  10. reflection-config.json:
  11. ```
  12. [
  13. {
  14. "name":"<Remote Service interface name>",
  15. "allDeclaredMethods":true
  16. }
  17. ]
  18. ```

Usage

1. Add redisson-quarkus dependency into your project:

Maven

  1. <dependency>
  2. <groupId>org.redisson</groupId>
  3. <!-- for Quarkus v1.6.x - v1.13.x -->
  4. <artifactId>redisson-quarkus-16</artifactId>
  5. <!-- for Quarkus v2.x.x -->
  6. <artifactId>redisson-quarkus-20</artifactId>
  7. <!-- for Quarkus v3.x.x -->
  8. <artifactId>redisson-quarkus-30</artifactId>
  9. <version>xVERSIONx</version>
  10. </dependency>

Gradle

  1. // for Quarkus v1.6.x - v1.13.x
  2. compile 'org.redisson:redisson-quarkus-16:xVERSIONx'
  3. // for Quarkus v2.x.x
  4. compile 'org.redisson:redisson-quarkus-20:xVERSIONx'
  5. // for Quarkus v3.x.x
  6. compile 'org.redisson:redisson-quarkus-30:xVERSIONx'

2. Add settings into application.properties file

Config structure is a flat Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode

NOTE: Setting names in camel case should be joined with hyphens (-).

Below is the configuration example for a single Redis or Valkey node setup.

  1. quarkus.redisson.single-server-config.address=redis://localhost:6379
  2. quarkus.redisson.single-server-config.password=null
  3. quarkus.redisson.threads=16
  4. quarkus.redisson.netty-threads=32

Use quarkus.redisson.file setting to specify path to a config file.

3. Use Redisson

  1. @Inject
  2. RedissonClient redisson;

Upgrade to Redisson PRO with advanced features.

Cache

For Quarkus Cache usage please refer to Quarkus Cache article.

Helidon

Redisson implements Helidon CDI extension for Redis.

Supports Helidon 1.4.x - 4.x.x

Usage

1. Add redisson-helidon dependency into your project:

Maven

  1. <dependency>
  2. <groupId>org.redisson</groupId>
  3. <!-- for Helidon v1.4.x - v2.5.x -->
  4. <artifactId>redisson-helidon-20</artifactId>
  5. <!-- for Helidon v3.x.x -->
  6. <artifactId>redisson-helidon-30</artifactId>
  7. <!-- for Helidon v4.x.x -->
  8. <artifactId>redisson-helidon-40</artifactId>
  9. <version>xVERSIONx</version>
  10. </dependency>

Gradle

  1. // for Helidon v1.4.x - v2.5.x
  2. compile 'org.redisson:redisson-helidon-20:xVERSIONx'
  3. // for Helidon v3.x.x
  4. compile 'org.redisson:redisson-helidon-30:xVERSIONx'
  5. // for Helidon v4.x.x
  6. compile 'org.redisson:redisson-helidon-40:xVERSIONx'

2. Add settings into META-INF/microprofile-config.properties file

Config structure is a flat Redisson YAML configuration - single mode, replicated mode, cluster mode, sentinel mode, proxy mode, multi cluster mode, multi sentinel mode

Below is the configuration example for Redisson instance named simple.

  1. org.redisson.Redisson.simple.singleServerConfig.address=redis://127.0.0.1:6379
  2. org.redisson.Redisson.simple.singleServerConfig.connectionPoolSize=64
  3. org.redisson.Redisson.simple.threads=16
  4. org.redisson.Redisson.simple.nettyThreads=32

3. Use Redisson

  1. @Inject
  2. @Named("simple")
  3. private RedissonClient redisson;

For injection without @Named annotation use instance name - default.

Upgrade to Redisson PRO with advanced features.