连接池设置

kiayqfof  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(295)

正在尝试在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;
    }

当我检查执行时,它没有考虑连接池,每次建立连接时都是这样。有什么线索吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题