use of redis.clients.jedis.JedisPoolConfig in project cas by apereo.
the class RedisTicketRegistryConfiguration method jedisPoolConfig.
private JedisPoolConfig jedisPoolConfig() {
final RedisTicketRegistryProperties redis = casProperties.getTicket().getRegistry().getRedis();
final JedisPoolConfig config = new JedisPoolConfig();
final RedisTicketRegistryProperties.Pool props = redis.getPool();
config.setMaxTotal(props.getMaxActive());
config.setMaxIdle(props.getMaxIdle());
config.setMinIdle(props.getMinIdle());
config.setMaxWaitMillis(props.getMaxWait());
return config;
}
use of redis.clients.jedis.JedisPoolConfig in project cas by apereo.
the class RedisTicketRegistryConfiguration method redisConnectionFactory.
@Bean
@RefreshScope
public RedisConnectionFactory redisConnectionFactory() {
final RedisTicketRegistryProperties redis = casProperties.getTicket().getRegistry().getRedis();
final JedisPoolConfig poolConfig = redis.getPool() != null ? jedisPoolConfig() : new JedisPoolConfig();
final JedisConnectionFactory factory = new JedisConnectionFactory(poolConfig);
factory.setHostName(redis.getHost());
factory.setPort(redis.getPort());
if (redis.getPassword() != null) {
factory.setPassword(redis.getPassword());
}
factory.setDatabase(redis.getDatabase());
if (redis.getTimeout() > 0) {
factory.setTimeout(redis.getTimeout());
}
return factory;
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method testCloseConnectionOnMakeObject.
@Test
public void testCloseConnectionOnMakeObject() {
JedisPoolConfig config = new JedisPoolConfig();
config.setTestOnBorrow(true);
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "wrong pass");
Jedis jedis = new Jedis("redis://:foobared@localhost:6379/");
int currentClientCount = getClientCount(jedis.clientList());
try {
pool.getResource();
fail("Should throw exception as password is incorrect.");
} catch (Exception e) {
assertEquals(currentClientCount, getClientCount(jedis.clientList()));
}
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method checkConnectionWithDefaultPort.
@Test
public void checkConnectionWithDefaultPort() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPoolConfig in project spring-cloud-connectors by spring-cloud.
the class RedisConnectionFactoryConfigurer method configurePool.
private void configurePool(JedisConnectionFactory connectionFactory, PooledServiceConnectorConfig config) {
if (config.getPoolConfig() != null) {
JedisPoolConfig poolConfig = new JedisPoolConfig();
BeanWrapper target = new BeanWrapperImpl(poolConfig);
BeanWrapper source = new BeanWrapperImpl(config.getPoolConfig());
Util.setCorrespondingProperties(target, source);
connectionFactory.setPoolConfig(poolConfig);
}
}
Aggregations