|
|
|
@ -33,13 +33,16 @@ import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Lettuce.Cluster.Refresh;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Pool;
|
|
|
|
|
import org.springframework.boot.autoconfigure.thread.Threading;
|
|
|
|
|
import org.springframework.boot.ssl.SslBundle;
|
|
|
|
|
import org.springframework.boot.ssl.SslBundles;
|
|
|
|
|
import org.springframework.boot.ssl.SslOptions;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
|
|
|
@ -83,9 +86,29 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
|
|
|
|
@ConditionalOnThreading(Threading.PLATFORM)
|
|
|
|
|
LettuceConnectionFactory redisConnectionFactory(
|
|
|
|
|
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
|
|
|
|
|
ClientResources clientResources) {
|
|
|
|
|
return createConnectionFactory(builderCustomizers, clientResources);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean(RedisConnectionFactory.class)
|
|
|
|
|
@ConditionalOnThreading(Threading.VIRTUAL)
|
|
|
|
|
LettuceConnectionFactory redisConnectionFactoryVirtualThreads(
|
|
|
|
|
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
|
|
|
|
|
ClientResources clientResources) {
|
|
|
|
|
LettuceConnectionFactory factory = createConnectionFactory(builderCustomizers, clientResources);
|
|
|
|
|
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor("redis-");
|
|
|
|
|
executor.setVirtualThreads(true);
|
|
|
|
|
factory.setExecutor(executor);
|
|
|
|
|
return factory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LettuceConnectionFactory createConnectionFactory(
|
|
|
|
|
ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers,
|
|
|
|
|
ClientResources clientResources) {
|
|
|
|
|
LettuceClientConfiguration clientConfig = getLettuceClientConfiguration(builderCustomizers, clientResources,
|
|
|
|
|
getProperties().getLettuce().getPool());
|
|
|
|
|
return createLettuceConnectionFactory(clientConfig);
|
|
|
|
|