redis.clients.jedis.Jedis.getClient()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(399)

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

Jedis.getClient介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

public static String getNodeKey(Jedis jedis) {
 return getNodeKey(jedis.getClient());
}

代码示例来源:origin: qiujiayu/AutoLoadCache

private void flushCachedData(Jedis jedis) {
  try {
    jedis.getClient().getAll();
  } catch (RuntimeException ex) {
    // 其中一个client出问题,后面出问题的几率较大
  }
}

代码示例来源:origin: qiujiayu/AutoLoadCache

private Client getClient(int slot) {
    JedisPool pool = clusterInfoCache.getSlotPool(slot);
    // 根据pool从缓存中获取Jedis
    Jedis jedis = jedisMap.get(pool);
    if (null == jedis) {
      jedis = pool.getResource();
      jedisMap.put(pool, jedis);
    }
    return jedis.getClient();
  }
}

代码示例来源:origin: sohutv/cachecloud

@Override
protected Client getClient(String key) {
 Client client = jedis.getShard(key).getClient();
 clients.add(client);
 results.add(new FutureResult(client));
 return client;
}

代码示例来源:origin: sohutv/cachecloud

@Override
 protected Client getClient(byte[] key) {
  Client client = jedis.getShard(key).getClient();
  clients.add(client);
  results.add(new FutureResult(client));
  return client;
 }
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

@Override
public Map<String, Object> getKeysSize() {
  long dbSize = (long) this.excuteByJedis(
      j -> {
        Client client = j.getClient();
        client.dbSize();
        return client.getIntegerReply();
      }
  );
  Map<String, Object> map = new HashMap<>();
  map.put("create_time", System.currentTimeMillis());
  map.put("dbSize", dbSize);
  return map;
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

@Override
public Map<String, Object> getMemoryInfo() {
  String info = (String) this.excuteByJedis(
      j -> {
        Client client = j.getClient();
        client.info();
        return client.getBulkReply();
      }
  );
  String[] strs = Objects.requireNonNull(info).split("\n");
  Map<String, Object> map = null;
  for (String s : strs) {
    String[] detail = s.split(":");
    if ("used_memory".equals(detail[0])) {
      map = new HashMap<>();
      map.put("used_memory", detail[1].substring(0, detail[1].length() - 1));
      map.put("create_time", System.currentTimeMillis());
      break;
    }
  }
  return map;
}

代码示例来源:origin: sohutv/cachecloud

public void discoverClusterNodesAndSlots(Jedis jedis) {
 w.lock();
 try {
  this.nodes.clear();
  this.slots.clear();
  String localNodes = jedis.clusterNodes();
  for (String nodeInfo : localNodes.split("\n")) {
   ClusterNodeInformation clusterNodeInfo = nodeInfoParser.parse(nodeInfo, new HostAndPort(
     jedis.getClient().getHost(), jedis.getClient().getPort()));
   HostAndPort targetNode = clusterNodeInfo.getNode();
   setNodeIfNotExist(targetNode);
   assignSlotsToNode(clusterNodeInfo.getAvailableSlots(), targetNode);
  }
 } finally {
  w.unlock();
 }
}

代码示例来源:origin: sohutv/cachecloud

public Jedis getNewJedis(String channel, int timeout) {
  Jedis jedis = getJedis(channel);
  try {
    String host = jedis.getClient().getHost();
    int port = jedis.getClient().getPort();
    Jedis newJedis = new Jedis(host, port, timeout);
    String pong = newJedis.ping();
    if (pong == null || !pong.equals("PONG")) {
      throw new JedisException("SubPubCluster:jedis is not ping !");
    }
    return newJedis;
  } finally {
    releaseConnection(jedis);
  }
}

代码示例来源:origin: sohutv/cachecloud

@Override
public Jedis getResource() {
 while (true) {
  Jedis jedis = super.getResource();
  jedis.setDataSource(this);
  // get a reference because it can change concurrently
  final HostAndPort master = currentHostMaster;
  final HostAndPort connection = new HostAndPort(jedis.getClient().getHost(), jedis.getClient()
    .getPort());
  if (master.equals(connection)) {
   // connected to the correct master
   return jedis;
  } else {
   returnBrokenResource(jedis);
  }
 }
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

@Override
public List<RedisInfo> getRedisInfo() {
  String info = (String) this.excuteByJedis(
      j -> {
        Client client = j.getClient();
        client.info();
        return client.getBulkReply();
      }
  );
  List<RedisInfo> infoList = new ArrayList<>();
  String[] strs = Objects.requireNonNull(info).split("\n");
  RedisInfo redisInfo;
  if (strs.length > 0) {
    for (String str1 : strs) {
      redisInfo = new RedisInfo();
      String[] str = str1.split(":");
      if (str.length > 1) {
        String key = str[0];
        String value = str[1];
        redisInfo.setKey(key);
        redisInfo.setValue(value);
        infoList.add(redisInfo);
      }
    }
  }
  return infoList;
}

代码示例来源:origin: sohutv/cachecloud

@Override
public void close() {
 if (dataSource != null) {
  boolean broken = false;
  for (Jedis jedis : getAllShards()) {
   if (jedis.getClient().isBroken()) {
    broken = true;
    break;
   }
  }
  if (broken) {
   dataSource.returnBrokenResource(this);
  } else {
   dataSource.returnResource(this);
  }
 } else {
  disconnect();
 }
}

代码示例来源:origin: spring-projects/spring-data-redis

private Jedis createJedis() {
  if (providedShardInfo) {
    return new Jedis(getShardInfo());
  }
  Jedis jedis = new Jedis(getHostName(), getPort(), getConnectTimeout(), getReadTimeout(), isUseSsl(),
      clientConfiguration.getSslSocketFactory().orElse(null), //
      clientConfiguration.getSslParameters().orElse(null), //
      clientConfiguration.getHostnameVerifier().orElse(null));
  Client client = jedis.getClient();
  getRedisPassword().map(String::new).ifPresent(client::setPassword);
  client.setDb(getDatabase());
  return jedis;
}

代码示例来源:origin: Impetus/Kundera

connection.getClient().setTimeoutInfinite();
Map props = RedisPropertyReader.rsmd.getProperties();

代码示例来源:origin: Impetus/Kundera

field.setAccessible(true);
Jedis connection=(Jedis) field.get(redisClient);
Assert.assertEquals(6379, connection.getClient().getPort());
Assert.assertEquals("localhost", connection.getClient().getHost());
Assert.assertEquals(20000, connection.getClient().getConnectionTimeout());

代码示例来源:origin: io.leopard/leopard-redis

@Override
public Client getClient() {
  Client client = jedis.getClient();
  System.out.println("client:" + client);
  return client;
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Client getClient() {
 String command = "getClient";
 return instrumented(command, () -> delegated.getClient());
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public Client getClient() {
  Jedis jedis = getJedis();
  try {
    return jedis.getClient();
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: iipc/openwayback

public Object makeObject() throws Exception {
  final Jedis jedis;
  jedis = new JedisValid(host, port, timeout);
  if (password != null) {
    jedis.getClient().setPassword(password);
  }
  jedis.connect();
  return jedis;
}

代码示例来源:origin: org.netpreserve.openwayback/openwayback-core

public Object makeObject() throws Exception {
  final Jedis jedis;
  jedis = new JedisValid(host, port, timeout);
  if (password != null) {
    jedis.getClient().setPassword(password);
  }
  jedis.connect();
  return jedis;
}

相关文章

微信公众号

最新文章

更多

Jedis类方法