本文整理匯總了Java中redis.clients.jedis.ShardedJedisPool.destroy方法的典型用法代碼示例。如果您正苦於以下問題:Java ShardedJedisPool.destroy方法的具體用法?Java ShardedJedisPool.destroy怎麽用?Java ShardedJedisPool.destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.ShardedJedisPool
的用法示例。
在下文中一共展示了ShardedJedisPool.destroy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testShardSimplePool
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
/**
* 分布式連接池同步調用
* 1.288 seconds
* 1.291 seconds
*/
@Test
public void testShardSimplePool() {
List<JedisShardInfo> shards = Arrays.asList(new JedisShardInfo(
"localhost", 6379), new JedisShardInfo("localhost", 6379));
ShardedJedisPool pool = new ShardedJedisPool(new JedisPoolConfig(), shards);
ShardedJedis one = pool.getResource();
long start = System.currentTimeMillis();
for (int i = 0; i < COUNTER; i++) {
String result = one.set("spn" + i, "n" + i);
}
long end = System.currentTimeMillis();
pool.returnResource(one);
logger.info("[email protected] SET: " + ((end - start) / 1000.0) + " seconds");
pool.destroy();
}
示例2: testShardPipelinedPool
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
/**
* 分布式連接池異步調用
* 0.452 seconds
* 0.43 seconds
*/
@Test
@Ignore
public void testShardPipelinedPool() {
List<JedisShardInfo> shards = Arrays.asList(
new JedisShardInfo("localhost",6379),
new JedisShardInfo("localhost",6379));
ShardedJedisPool pool = new ShardedJedisPool(new JedisPoolConfig(), shards);
ShardedJedis one = pool.getResource();
ShardedJedisPipeline pipeline = one.pipelined();
long start = System.currentTimeMillis();
for (int i = 0; i < COUNTER; i++) {
pipeline.set("sppn" + i, "n" + i);
}
List<Object> results = pipeline.syncAndReturnAll();
long end = System.currentTimeMillis();
pool.returnResource(one);
logger.info("[email protected] SET: " + ((end - start)/1000.0) + " seconds");
pool.destroy();
}
示例3: checkConnections
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkConnections() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
pool.returnResource(jedis);
pool.destroy();
}
示例4: checkConnectionWithDefaultPort
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkConnectionWithDefaultPort() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
pool.returnResource(jedis);
pool.destroy();
}
示例5: checkJedisIsReusedWhenReturned
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkJedisIsReusedWhenReturned() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "0");
pool.returnResource(jedis);
jedis = pool.getResource();
jedis.incr("foo");
pool.returnResource(jedis);
pool.destroy();
}
示例6: checkPoolRepairedWhenJedisIsBroken
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.disconnect();
pool.returnBrokenResource(jedis);
jedis = pool.getResource();
jedis.incr("foo");
pool.returnResource(jedis);
pool.destroy();
}
示例7: checkFailedJedisServer
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkFailedJedisServer() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.incr("foo");
pool.returnResource(jedis);
pool.destroy();
}
示例8: returnResourceShouldResetState
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() throws URISyntaxException {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));
ShardedJedisPool pool = new ShardedJedisPool(config, shards);
ShardedJedis jedis = pool.getResource();
jedis.set("pipelined", String.valueOf(0));
jedis.set("pipelined2", String.valueOf(0));
ShardedJedisPipeline pipeline = jedis.pipelined();
pipeline.incr("pipelined");
pipeline.incr("pipelined2");
jedis.resetState();
pipeline = jedis.pipelined();
pipeline.incr("pipelined");
pipeline.incr("pipelined2");
List<Object> results = pipeline.syncAndReturnAll();
assertEquals(2, results.size());
pool.returnResource(jedis);
pool.destroy();
}
示例9: checkConnections
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkConnections() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
}
示例10: checkConnectionWithDefaultPort
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkConnectionWithDefaultPort() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
}
示例11: checkJedisIsReusedWhenReturned
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkJedisIsReusedWhenReturned() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "0");
jedis.close();
jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
示例12: checkPoolRepairedWhenJedisIsBroken
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.disconnect();
jedis.close();
jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
示例13: checkFailedJedisServer
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkFailedJedisServer() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
示例14: returnResourceShouldResetState
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() throws URISyntaxException {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));
ShardedJedisPool pool = new ShardedJedisPool(config, shards);
ShardedJedis jedis = pool.getResource();
jedis.set("pipelined", String.valueOf(0));
jedis.set("pipelined2", String.valueOf(0));
ShardedJedisPipeline pipeline = jedis.pipelined();
pipeline.incr("pipelined");
pipeline.incr("pipelined2");
jedis.resetState();
pipeline = jedis.pipelined();
pipeline.incr("pipelined");
pipeline.incr("pipelined2");
List<Object> results = pipeline.syncAndReturnAll();
assertEquals(2, results.size());
jedis.close();
pool.destroy();
}
示例15: testShardSimplePool
import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
public void testShardSimplePool() {// 12.642秒
JedisShardInfo jedis = new JedisShardInfo("120.25.241.144", 6379);
jedis.setPassword("b840fc02d52404542994");
List<JedisShardInfo> shards = Arrays.asList(jedis);
ShardedJedisPool pool = new ShardedJedisPool(new JedisPoolConfig(), shards);
ShardedJedis sharding = pool.getResource();
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
sharding.set("n" + i, "n" + i);
System.out.println(i);
}
long end = System.currentTimeMillis();
System.out.println("共花費:" + (end - start) / 1000.0 + "秒");
sharding.disconnect();
pool.destroy();
try {
Closeables.close(sharding, true);
Closeables.close(pool, true);
} catch (IOException e) {
e.printStackTrace();
}
}