redis与绝地武士的连接问题

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

我正在使用此代码,但遇到连接问题:

JedisConnectionFactory jedisConnectionFactory() {

    JedisConnectionFactory jedisConnectionFactory = null;
    try {
        RedisStandaloneConfiguration redisStandAloneConfiguration = new RedisStandaloneConfiguration(hostName,
            port);
        // make jedis connection factory thread safe (for multi-threaded
        // environment)
        JedisClientConfiguration jedisClientConfiguration = JedisClientConfiguration.builder().usePooling().build();
        jedisConnectionFactory = new JedisConnectionFactory(redisStandAloneConfiguration, jedisClientConfiguration);
        // jedisConnectionFactory uses connection pool by default but with
        // max total of 8
        jedisConnectionFactory.getPoolConfig().setMaxTotal(50);
        jedisConnectionFactory.getPoolConfig().setMaxIdle(50);
        jedisConnectionFactory.afterPropertiesSet();
    } catch (RedisConnectionFailureException e) {
        LOGGER.error("RedisConnectionFailureException in RedisConnector class, Connection break with JEDIS " +
            e.getMessage());
    }

    return jedisConnectionFactory;
}

暂无答案!

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

相关问题