当前位置: 首页>>代码示例>>Java>>正文


Java JedisPool.destroy方法代码示例

本文整理汇总了Java中redis.clients.jedis.JedisPool.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPool.destroy方法的具体用法?Java JedisPool.destroy怎么用?Java JedisPool.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.JedisPool的用法示例。


在下文中一共展示了JedisPool.destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkJedisIsReusedWhenReturned

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void checkJedisIsReusedWhenReturned() {

  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");
  pool.returnResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:JedisPoolTest.java

示例2: nonDefaultDatabase

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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"));
  pool0.returnResource(jedis0);
  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"));
  pool1.returnResource(jedis1);
  pool1.destroy();
  assertTrue(pool1.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:JedisPoolTest.java

示例3: selectDatabaseOnActivation

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void selectDatabaseOnActivation() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "foobared");

  Jedis jedis0 = pool.getResource();
  assertEquals(0L, jedis0.getDB().longValue());

  jedis0.select(1);
  assertEquals(1L, jedis0.getDB().longValue());

  pool.returnResource(jedis0);

  Jedis jedis1 = pool.getResource();
  assertTrue("Jedis instance was not reused", jedis1 == jedis0);
  assertEquals(0L, jedis1.getDB().longValue());

  pool.returnResource(jedis1);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:22,代码来源:JedisPoolTest.java

示例4: getNumActiveReturnsTheCorrectNumber

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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());

  pool.returnResource(jedis);
  assertEquals(1, pool.getNumActive());

  pool.returnResource(jedis2);

  assertEquals(0, pool.getNumActive());

  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:JedisPoolTest.java

示例5: testAddObject

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void testAddObject() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
  pool.addObjects(1);
  assertEquals(pool.getNumIdle(), 1);
  pool.destroy();

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:JedisPoolTest.java

示例6: checkConnections

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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"));
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:JedisPoolTest.java

示例7: checkConnectionWithDefaultPort

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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"));
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:JedisPoolTest.java

示例8: checkPoolRepairedWhenJedisIsBroken

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.quit();
  pool.returnBrokenResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:16,代码来源:JedisPoolTest.java

示例9: securePool

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:12,代码来源:JedisPoolTest.java

示例10: customClientName

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@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());

  pool0.returnResource(jedis);
  pool0.destroy();
  assertTrue(pool0.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:14,代码来源:JedisPoolTest.java

示例11: returnResourceShouldResetState

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void returnResourceShouldResetState() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");

  Jedis jedis = pool.getResource();
  try {
    jedis.set("hello", "jedis");
    Transaction t = jedis.multi();
    t.set("hello", "world");
  } finally {
    jedis.close();
  }

  Jedis jedis2 = pool.getResource();
  try {
    assertTrue(jedis == jedis2);
    assertEquals("jedis", jedis2.get("hello"));
  } finally {
    jedis2.close();
  }

  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:28,代码来源:JedisPoolTest.java

示例12: getNumActiveIsNegativeWhenPoolIsClosed

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void getNumActiveIsNegativeWhenPoolIsClosed() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "foobared", 0, "my_shiny_client_name");

  pool.destroy();
  assertTrue(pool.getNumActive() < 0);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:JedisPoolTest.java

示例13: withPool

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
private static void withPool() throws Exception {
  final JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), hnp.getHost(),
      hnp.getPort(), 2000, "foobared");
  List<Thread> tds = new ArrayList<Thread>();

  final AtomicInteger ind = new AtomicInteger();
  for (int i = 0; i < 50; i++) {
    Thread hj = new Thread(new Runnable() {
      public void run() {
        for (int i = 0; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS;) {
          try {
            Jedis j = pool.getResource();
            final String key = "foo" + i;
            j.set(key, key);
            j.get(key);
            pool.returnResource(j);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }
    });
    tds.add(hj);
    hj.start();
  }

  for (Thread t : tds)
    t.join();

  pool.destroy();

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:33,代码来源:PoolBenchmark.java

示例14: doTest

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
private static void doTest() throws Exception {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMinIdle(0);
    poolConfig.setMaxIdle(5);
    poolConfig.setMaxTotal(5);
    final JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", 6379, 2000, "weimob123", 8);

    List<Thread> tds = new ArrayList<Thread>();
    final Integer temp = 0;
    final AtomicInteger ind = new AtomicInteger();
    for (int i = 0; i < 50; i++) {
        Thread hj = new Thread(new Runnable() {
            public void run() {
                for (int i; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS; ) {
                    Jedis j = pool.getResource();
                    final String key = "foo" + i;
                    // redisUtil.setRedisData(key, key);
                    j.set(key.getBytes(), ConvertUtil.serialize(temp));
                    j.close();
                }
            }
        });
        tds.add(hj);
        hj.start();
    }

    for (Thread t : tds)
        t.join();
    pool.close();
    pool.destroy();
}
 
开发者ID:TwoDragonLake,项目名称:tdl-seckill,代码行数:32,代码来源:JedisTest.java

示例15: withPool

import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
private static void withPool() throws Exception {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    // poolConfig.setMinIdle(0);
    // poolConfig.setMaxIdle(5);
    // poolConfig.setMaxTotal(5);
    final JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", 6379, 2000, "weimob123", 0);
    List<Thread> tds = new ArrayList<Thread>();

    final AtomicInteger ind = new AtomicInteger();
    for (int i = 0; i < 50; i++) {
        Thread hj = new Thread(new Runnable() {
            public void run() {
                for (; ind.getAndIncrement() < TOTAL_OPERATIONS; ) {
                    try {
                        Jedis j = pool.getResource();
                        // final String key = "foo" + i;
                        // j.setRedisData(key, key);
                        // j.getRedisData(key);
                        j.get("foo1");
                        j.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        tds.add(hj);
        hj.start();
    }

    for (Thread t : tds)
        t.join();

    pool.destroy();

}
 
开发者ID:TwoDragonLake,项目名称:tdl-seckill,代码行数:37,代码来源:PoolTest.java


注:本文中的redis.clients.jedis.JedisPool.destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。