在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;
}
当我检查执行情况时,它没有考虑连接池,并且每次都建立连接。有指针吗?