本文整理了Java中redis.clients.util.Pool.isClosed()
方法的一些代码示例,展示了Pool.isClosed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pool.isClosed()
方法的具体详情如下:
包路径:redis.clients.util.Pool
类名称:Pool
方法名:isClosed
暂无
代码示例来源:origin: com.intoverflow.booster/booster-core
public void closePool() {
if (!jedisPool.isClosed()) {
jedisPool.close();
}
}
代码示例来源:origin: net.oschina.j2cache/j2cache-core
/**
* 加入 Redis 的发布订阅频道
*/
@Override
public void connect(Properties props, CacheProviderHolder holder) {
long ct = System.currentTimeMillis();
this.holder = holder;
this.publish(Command.join());
Thread subscribeThread = new Thread(()-> {
//当 Redis 重启会导致订阅线程断开连接,需要进行重连
while(!client.isClosed()) {
try (Jedis jedis = client.getResource()){
jedis.subscribe(this, channel);
log.info("Disconnect to redis channel: {}", channel);
break;
} catch (JedisConnectionException e) {
log.error("Failed connect to redis, reconnect it.", e);
if(!client.isClosed())
try {
Thread.sleep(1000);
} catch (InterruptedException ie){
break;
}
}
}
}, "RedisSubscribeThread");
subscribeThread.setDaemon(true);
subscribeThread.start();
log.info("Connected to redis channel:{}, time {} ms.", channel, (System.currentTimeMillis()-ct));
}
代码示例来源:origin: ai.grakn/redisq
if (jedisPool.isClosed()) {
throw new SubscriptionInterruptedException("Subscription interrupted because the Jedis connection was closed for id " + id, e);
} else {
内容来源于网络,如有侵权,请联系作者删除!