You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.5 KiB
3.5 KiB
Quarkus extension for Redis
Integrates Redisson with Quarkus framework. Implements Quarkus Cache.
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.
-H:DynamicProxyConfigurationResources=dynamic-proxy.json,-H:ReflectionConfigurationFiles=reflection-config.json
dynamic-proxy.json:
[
["<Remote Service interface name>"]
]
reflection-config.json:
[
{
"name":"<Remote Service interface name>",
"allDeclaredMethods":true
}
]
Cache usage
1. Add redisson-quarkus-cache
dependency into your project:
Maven
<dependency>
<groupId>org.redisson</groupId>
<!-- for Quarkus v3.x.x -->
<artifactId>redisson-quarkus-30-cache</artifactId>
<version>3.31.0</version>
</dependency>
Gradle
// for Quarkus v3.x.x
compile 'org.redisson:redisson-quarkus-30-cache:3.31.0'
2. Add settings into application.properties
file
expire-after-write
setting defines time to live of the item stored in the cache
expire-after-access
setting defines time to live added to the item after read operation
quarkus.cache.type=redisson
# Default configuration
quarkus.cache.redisson.expire-after-write=5s
quarkus.cache.redisson.expire-after-access=1s
# Configuration for `sampleCache`
quarkus.cache.redisson.sampleCache.expire-after-write=100s
quarkus.cache.redisson.sampleCache.expire-after-access=10s
Redisson usage
1. Add redisson-quarkus
dependency into your project:
Maven
<dependency>
<groupId>org.redisson</groupId>
<!-- for Quarkus v1.6.x - v1.13.x -->
<artifactId>redisson-quarkus-16</artifactId>
<!-- for Quarkus v2.x.x -->
<artifactId>redisson-quarkus-20</artifactId>
<!-- for Quarkus v3.x.x -->
<artifactId>redisson-quarkus-30</artifactId>
<version>3.31.0</version>
</dependency>
Gradle
// for Quarkus v1.6.x - v1.13.x
compile 'org.redisson:redisson-quarkus-16:3.31.0'
// for Quarkus v2.x.x
compile 'org.redisson:redisson-quarkus-20:3.31.0'
// for Quarkus v3.x.x
compile 'org.redisson:redisson-quarkus-30:3.31.0'
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
NOTE: Setting names in camel case should be joined with hyphens (-).
Below is the configuration example for a single Redis node setup.
quarkus.redisson.single-server-config.address=redis://localhost:6379
quarkus.redisson.single-server-config.password=null
quarkus.redisson.threads=16
quarkus.redisson.netty-threads=32
Use quarkus.redisson.file
setting to specify path to a config file.
3. Use Redisson
@Inject
RedissonClient redisson;
Upgrade to Redisson PRO with advanced features.