Search in sources :

Example 16 with JedisPoolConfig

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

the class JedisPoolTest method checkConnections.

@Test
public void checkConnections() {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
    Jedis jedis = pool.getResource();
    jedis.auth("foobared");
    jedis.set("foo", "bar");
    assertEquals("bar", jedis.get("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 17 with JedisPoolConfig

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

the class JedisPoolTest method getNumActiveReturnsTheCorrectNumber.

@Test
public void getNumActiveReturnsTheCorrectNumber() {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
    Jedis jedis = pool.getResource();
    jedis.auth("foobared");
    jedis.set("foo", "bar");
    assertEquals("bar", jedis.get("foo"));
    assertEquals(1, pool.getNumActive());
    Jedis jedis2 = pool.getResource();
    jedis.auth("foobared");
    jedis.set("foo", "bar");
    assertEquals(2, pool.getNumActive());
    jedis.close();
    assertEquals(1, pool.getNumActive());
    jedis2.close();
    assertEquals(0, pool.getNumActive());
    pool.destroy();
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 18 with JedisPoolConfig

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

the class JedisPoolTest method checkCloseableConnections.

@Test
public void checkCloseableConnections() throws Exception {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
    Jedis jedis = pool.getResource();
    jedis.auth("foobared");
    jedis.set("foo", "bar");
    assertEquals("bar", jedis.get("foo"));
    jedis.close();
    pool.close();
    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 19 with JedisPoolConfig

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

the class JedisPoolTest method nonDefaultDatabase.

@Test
public void nonDefaultDatabase() {
    JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared");
    Jedis jedis0 = pool0.getResource();
    jedis0.set("foo", "bar");
    assertEquals("bar", jedis0.get("foo"));
    jedis0.close();
    pool0.destroy();
    assertTrue(pool0.isClosed());
    JedisPool pool1 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 1);
    Jedis jedis1 = pool1.getResource();
    assertNull(jedis1.get("foo"));
    jedis1.close();
    pool1.destroy();
    assertTrue(pool1.isClosed());
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 20 with JedisPoolConfig

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

the class JedisPoolTest method customClientName.

@Test
public void customClientName() {
    JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 0, "my_shiny_client_name");
    Jedis jedis = pool0.getResource();
    assertEquals("my_shiny_client_name", jedis.clientGetname());
    jedis.close();
    pool0.destroy();
    assertTrue(pool0.isClosed());
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

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