2

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?

BharathyKannan
  • 148
  • 2
  • 3
  • 19
  • What makes you say that it doesn't consider the connection pool? `setMaxTotal(100)` should result in a pool of a 100 connections maximum. Perhaps that's what you're seeing? Have you tried setting it to a much lower number and observe? Default is 8. – solimant May 31 '20 at 11:53
  • I used similar code with `LettucePoolingClientConfiguration` and 1. I didn't see a lot of connections to my Redis (like with Jedis), connection(s) were blocked and everything worked waaay slower than with Jedis. – razor Apr 14 '22 at 15:24

0 Answers0