Spring Data Redis - Lettuce Connection Pool Setting

Viewed 3694

Trying to setup Lettuce Connection Pool in spring data redis environment.
Below is the code

    @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;
    }

When I checked the execution it is not considering the Connection pool and every time connection is established. Any pointer on this?

0 Answers
Related