private static JedisPoolConfig createJedisPoolConfig(final PropertyContext context) { final JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(context.getProperty(RedisUtils.POOL_MAX_TOTAL).asInteger()); poolConfig.setMaxIdle(context.getProperty(RedisUtils.POOL_MAX_IDLE).asInteger()); poolConfig.setMinIdle(context.getProperty(RedisUtils.POOL_MIN_IDLE).asInteger()); poolConfig.setBlockWhenExhausted(context.getProperty(RedisUtils.POOL_BLOCK_WHEN_EXHAUSTED).asBoolean()); poolConfig.setMaxWaitMillis(context.getProperty(RedisUtils.POOL_MAX_WAIT_TIME).asTimePeriod(TimeUnit.MILLISECONDS)); poolConfig.setMinEvictableIdleTimeMillis(context.getProperty(RedisUtils.POOL_MIN_EVICTABLE_IDLE_TIME).asTimePeriod(TimeUnit.MILLISECONDS)); poolConfig.setTimeBetweenEvictionRunsMillis(context.getProperty(RedisUtils.POOL_TIME_BETWEEN_EVICTION_RUNS).asTimePeriod(TimeUnit.MILLISECONDS)); poolConfig.setNumTestsPerEvictionRun(context.getProperty(RedisUtils.POOL_NUM_TESTS_PER_EVICTION_RUN).asInteger()); poolConfig.setTestOnCreate(context.getProperty(RedisUtils.POOL_TEST_ON_CREATE).asBoolean()); poolConfig.setTestOnBorrow(context.getProperty(RedisUtils.POOL_TEST_ON_BORROW).asBoolean()); poolConfig.setTestOnReturn(context.getProperty(RedisUtils.POOL_TEST_ON_RETURN).asBoolean()); poolConfig.setTestWhileIdle(context.getProperty(RedisUtils.POOL_TEST_WHILE_IDLE).asBoolean()); return poolConfig; }
/** * Constructs JedisPoolConfig object. * * @param poolSize size of the JedisPool * @return {@link JedisPoolConfig} object with a few default settings */ private static JedisPoolConfig initPoolConfig(int poolSize) { JedisPoolConfig conf = new JedisPoolConfig(); conf.setMaxTotal(poolSize); conf.setTestOnBorrow(false); conf.setTestOnReturn(false); conf.setTestOnCreate(false); conf.setTestWhileIdle(false); conf.setMinEvictableIdleTimeMillis(60000); conf.setTimeBetweenEvictionRunsMillis(30000); conf.setNumTestsPerEvictionRun(-1); conf.setFairness(true); return conf; }
poolConfig.setTestOnCreate(testOnCreate);
private static JedisPoolConfig createJedisPoolConfig(Builder builder) { JedisPoolConfig config = new JedisPoolConfig(); config.setMaxTotal(builder.maxTotal); config.setMaxIdle(builder.maxIdle); config.setMinIdle(builder.minIdle); config.setLifo(builder.lifo); config.setFairness(builder.fairness); config.setMaxWaitMillis(builder.maxWaitMillis); config.setMinEvictableIdleTimeMillis(builder.minEvictableIdleTimeMillis); config.setSoftMinEvictableIdleTimeMillis(builder.softMinEvictableIdleTimeMillis); config.setNumTestsPerEvictionRun(builder.numTestsPerEvictionRun); config.setTestOnCreate(builder.testOnCreate); config.setTestOnBorrow(builder.testOnBorrow); config.setTestOnReturn(builder.testOnReturn); config.setTestWhileIdle(builder.testWhileIdle); config.setTimeBetweenEvictionRunsMillis(builder.timeBetweenEvictionRunsMillis); config.setEvictionPolicyClassName(builder.evictionPolicyClassName); config.setBlockWhenExhausted(builder.blockWhenExhausted); config.setJmxEnabled(builder.jmxEnabled); config.setJmxNameBase(builder.jmxNameBase); config.setJmxNamePrefix(builder.jmxNamePrefix); return config; }
poolConfig.setTestOnCreate(config.getTestOnCreate());