redisson-starter

A spring boot starter that configures redisson client and optionally some utility beans

License

License

Categories

Categories

Redis Data Databases Redisson
GroupId

GroupId

se.svt.oss
ArtifactId

ArtifactId

redisson-starter
Last Version

Last Version

1.1.3
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

redisson-starter
A spring boot starter that configures redisson client and optionally some utility beans
Project URL

Project URL

https://github.com/svt/redisson-starter
Source Code Management

Source Code Management

https://github.com/svt/redisson-starter/

Download redisson-starter

Dependencies

compile (1)

Group / Artifact Type Version
org.redisson : redisson jar 3.14.1

runtime (5)

Group / Artifact Type Version
io.github.microutils : kotlin-logging jar 1.7.4
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.41
org.jetbrains.kotlin : kotlin-reflect jar 1.3.41
org.springframework.boot : spring-boot jar 2.2.6.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.2.6.RELEASE

Project Modules

There are no modules declared in this project.

REUSE status

redisson-starter

Spring boot starter that configures a redisson client. In addition to configuring the redisson client, it also optionally provides additional services for working with redisson locks and queues:

  • RedissonLockService A service that provied a tryWithLock method that uses a redisson lock. A bean will be provided if redis.redisson.lock.name-prefix property is set.
  • RedissonLibQeueue If redis.redisson.queue.name property is set, a redisson priority queue will be provided.

This library is written in kotlin.

Usage

Add the lib as a dependency to your build.gradle

implementation 'se.svt.oss:redisson-starter:1.1.0'

Configure in application.yml (or other property source) :

redis:
  uri: redis://localhost:6379
  db: 0
  redisson:
    lock:
      name: ${service.name}-lock
      wait-time: 0s
      lease-time: 60m
    queue:
      name: ${service.name}-queue

For the lock service, name, wait-time and lease-time only configures default values that can be overriden when calling the lock service:

redissonLockService.tryWithLock(name = "my-other-lock", 
                                waitTime = Duration.ofSeconds(10),
                                leaseTime = Duration.ofHours(1)) {
   // DO SOME STUFF WITH LOCK
}

Mocking the RedissonLockService with mockk

Calling RedissonLockService.tryWithLock on a mockk object without specifiying all parameters will fail, because the default parameter values reference an instance field that will not be available. To get around this, a spy can be used instead:

private val redissonLockService = spyk(RedissonLockService(mockk(), mockk(relaxed = true)))

Contributing

Tests

run ./gradlew check for unit tests and code quality checks

License

Copyright 2020 Sveriges Television AB

This software is released under the Apache 2.0 License.

Primary Maintainers

SVT Videocore team [email protected]

se.svt.oss

Sveriges Television (SVT)

The Swedish public service television company

Versions

Version
1.1.3