use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.
the class RedisAutoConfigurationTests method testRedisConfigurationWithCustomPoolSettings.
@Test
void testRedisConfigurationWithCustomPoolSettings() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.lettuce.pool.min-idle:1", "spring.redis.lettuce.pool.max-idle:4", "spring.redis.lettuce.pool.max-active:16", "spring.redis.lettuce.pool.max-wait:2000", "spring.redis.lettuce.pool.time-between-eviction-runs:30000", "spring.redis.lettuce.shutdown-timeout:1000").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
GenericObjectPoolConfig<?> poolConfig = getPoolingClientConfiguration(cf).getPoolConfig();
assertThat(poolConfig.getMinIdle()).isEqualTo(1);
assertThat(poolConfig.getMaxIdle()).isEqualTo(4);
assertThat(poolConfig.getMaxTotal()).isEqualTo(16);
assertThat(poolConfig.getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2));
assertThat(poolConfig.getDurationBetweenEvictionRuns()).isEqualTo(Duration.ofSeconds(30));
assertThat(cf.getShutdownTimeout()).isEqualTo(1000);
});
}
use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.
the class RedisAutoConfigurationLettuceWithoutCommonsPool2Tests method poolWithoutCommonsPool2IsDisabledByDefault.
@Test
void poolWithoutCommonsPool2IsDisabledByDefault() {
this.contextRunner.withPropertyValues("spring.redis.host:foo").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getClientConfiguration()).isNotInstanceOf(LettucePoolingClientConfiguration.class);
});
}
use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.
the class RedisAutoConfigurationTests method testOverrideRedisConfiguration.
@Test
void testOverrideRedisConfiguration() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1", "spring.redis.lettuce.shutdown-timeout:500").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1);
assertThat(getUserName(cf)).isNull();
assertThat(cf.getPassword()).isNull();
assertThat(cf.isUseSsl()).isFalse();
assertThat(cf.getShutdownTimeout()).isEqualTo(500);
});
}
use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project dhis2-core by dhis2.
the class RedisConfiguration method lettuceConnectionFactory.
@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
LettuceClientConfigurationBuilder builder = LettuceClientConfiguration.builder();
if (DhisConfigurationProvider.isOn((String) redisSslEnabled().getObject())) {
builder.useSsl();
}
LettuceClientConfiguration clientConfiguration = builder.build();
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
standaloneConfig.setHostName((String) redisHost().getObject());
standaloneConfig.setPassword((String) redisPassword().getObject());
standaloneConfig.setPort(Integer.parseInt((String) redisPort().getObject()));
return new LettuceConnectionFactory(standaloneConfig, clientConfiguration);
}
use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RedisConnectionFactoryCloudConfigTestHelper method assertPoolProperties.
public static void assertPoolProperties(RedisConnectionFactory connector, int maxActive, int minIdle, long maxWait) {
GenericObjectPoolConfig poolConfig = null;
if (connector instanceof JedisConnectionFactory) {
poolConfig = ((JedisConnectionFactory) connector).getPoolConfig();
} else if (connector instanceof LettuceConnectionFactory) {
LettuceClientConfiguration config = ((LettuceConnectionFactory) connector).getClientConfiguration();
assertThat(config, instanceOf(LettucePoolingClientConfiguration.class));
poolConfig = ((LettucePoolingClientConfiguration) config).getPoolConfig();
}
assertCommonsPoolProperties(poolConfig, maxActive, minIdle, maxWait);
}
Aggregations