正在尝试在spring数据redis环境中设置连接池。
下面是代码
@Bean
LettuceConnectionFactory redisConnectionFactory(GenericObjectPoolConfig genericObjectPoolConfig) {
RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration();
redisConfiguration.setHostName(hostName);
redisConfiguration.setPort(port);
redisConfiguration.setPassword(password);
redisConfiguration.setDatabase(databaseIndex);
LettuceClientConfiguration lettuceClientConfiguration= LettucePoolingClientConfiguration.builder().poolConfig(genericObjectPoolConfig).build();
return new LettuceConnectionFactory(redisConfiguration,lettuceClientConfiguration);
}
@Bean
public GenericObjectPoolConfig genericObjectPoolConfig(){
GenericObjectPoolConfig genericObjectPoolConfig=new GenericObjectPoolConfig();
genericObjectPoolConfig.setMaxTotal(100);
return genericObjectPoolConfig;
}
当我检查执行时,它没有考虑连接池,每次建立连接时都是这样。有什么线索吗?
暂无答案!
目前还没有任何答案,快来回答吧!