Spring Data Redis-生菜连接池设置

时间:2020-04-11 16:21:01

标签: redis spring-data-redis lettuce

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

当我检查执行情况时,它没有考虑连接池,并且每次都建立连接。有指针吗?

0 个答案:

没有答案