redis.clients.util.Pool.isClosed()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中redis.clients.util.Pool.isClosed()方法的一些代码示例,展示了Pool.isClosed()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pool.isClosed()方法的具体详情如下:
包路径:redis.clients.util.Pool
类名称:Pool
方法名:isClosed

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 {

相关文章