Skip to content

Commit

Permalink
try switch lettuce with jedis
Browse files Browse the repository at this point in the history
  • Loading branch information
kenglxn committed Sep 18, 2023
1 parent a49d187 commit d9ce1a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package no.nav.arbeidsgiver.altinnrettigheter.proxy.config

import io.lettuce.core.RedisURI
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.data.redis.connection.RedisStandaloneConfiguration
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory
import java.net.URI


@Configuration
class RedisConfig {

Expand All @@ -16,7 +16,7 @@ class RedisConfig {
* nais exposes url, username and password, but RedisURI expects usename and password to be part of the url
* https://lettuce.io/core/release/api/io/lettuce/core/RedisURI.html
*
* see also org.springframework.boot.autoconfigure.data.redis.RedisProperties.url which says
* see org.springframework.boot.autoconfigure.data.redis.RedisProperties.url which says
* "Connection URL. Overrides host, port, and password. User is ignored. Example: redis://user:password@example.com:6379"
*/
@Bean
Expand All @@ -33,12 +33,5 @@ class RedisConfig {
}

@Bean
fun lettuceClientConfigurationCustomizer(
@Value("\${spring.data.redis.url}") redisUrl: URI,
) = LettuceClientConfigurationBuilderCustomizer {
it.apply(RedisURI.create(redisUrl).apply {
// TODO: dont do this in prod
isVerifyPeer = false
})
}
fun redisConnectionFactory(config: RedisStandaloneConfiguration) = JedisConnectionFactory(config)
}
4 changes: 3 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ spring:
banner-mode: off
data:
redis:
client-type: jedis
password: ${REDIS_PASSWORD_ALTINNRETTIGHETER:}
username: ${REDIS_USERNAME_ALTINNRETTIGHETER:}
url: ${REDIS_URI_ALTINNRETTIGHETER:redis://127.0.0.1:6379}
ssl: true
timeout: 2000
lettuce:
jedis:
pool:
max-active: 16
min-idle: 8
Expand Down

0 comments on commit d9ce1a6

Please sign in to comment.