Search in sources :

Example 21 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.

the class JedisPoolTest method testAddObject.

@Test
public void testAddObject() {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
    pool.addObjects(1);
    assertEquals(pool.getNumIdle(), 1);
    pool.destroy();
}
Also used : JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 22 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.

the class JedisPoolTest method selectDatabaseOnActivation.

@Test
public void selectDatabaseOnActivation() {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared");
    Jedis jedis0 = pool.getResource();
    assertEquals(0, jedis0.getDB());
    jedis0.select(1);
    assertEquals(1, jedis0.getDB());
    jedis0.close();
    Jedis jedis1 = pool.getResource();
    assertTrue("Jedis instance was not reused", jedis1 == jedis0);
    assertEquals(0, jedis1.getDB());
    jedis1.close();
    pool.destroy();
    assertTrue(pool.isClosed());
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 23 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.

the class JedisPoolTest method checkPoolRepairedWhenJedisIsBroken.

@Test
public void checkPoolRepairedWhenJedisIsBroken() {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
    Jedis jedis = pool.getResource();
    jedis.auth("foobared");
    jedis.quit();
    jedis.close();
    jedis = pool.getResource();
    jedis.auth("foobared");
    jedis.incr("foo");
    jedis.close();
    pool.destroy();
    assertTrue(pool.isClosed());
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 24 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.

the class JedisPoolTest method securePool.

@Test
public void securePool() {
    JedisPoolConfig config = new JedisPoolConfig();
    config.setTestOnBorrow(true);
    JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");
    Jedis jedis = pool.getResource();
    jedis.set("foo", "bar");
    jedis.close();
    pool.destroy();
    assertTrue(pool.isClosed());
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 25 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project oxCore by GluuFederation.

the class RedisProvider method create.

public void create() {
    log.debug("Starting RedisProvider ...");
    try {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(1000);
        poolConfig.setMinIdle(2);
        pool = new JedisPool(poolConfig, redisConfiguration.getHost(), redisConfiguration.getPort());
        testConnection();
        log.debug("RedisProvider started.");
    } catch (Exception e) {
        throw new IllegalStateException("Error starting RedisProvider", e);
    }
}
Also used : JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Aggregations

JedisPoolConfig (redis.clients.jedis.JedisPoolConfig)55 JedisPool (redis.clients.jedis.JedisPool)40 Test (org.junit.Test)31 Jedis (redis.clients.jedis.Jedis)29 HostAndPort (redis.clients.jedis.HostAndPort)7 JedisCluster (redis.clients.jedis.JedisCluster)7 LinkedHashSet (java.util.LinkedHashSet)4 HashSet (java.util.HashSet)3 RedisTicketRegistryProperties (org.apereo.cas.configuration.model.support.redis.RedisTicketRegistryProperties)3 URISyntaxException (java.net.URISyntaxException)2 Before (org.junit.Before)2 JedisConnectionFactory (org.springframework.data.redis.connection.jedis.JedisConnectionFactory)2 InvalidURIException (redis.clients.jedis.exceptions.InvalidURIException)2 JedisException (redis.clients.jedis.exceptions.JedisException)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 JedisPool (io.leopard.redis.JedisPool)1 RedisConnectionListener (io.leopard.redis.RedisConnectionListener)1 IOException (java.io.IOException)1 BeanWrapper (org.springframework.beans.BeanWrapper)1 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)1