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

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

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

Jedis.hgetAll介绍

[英]Return all the fields and associated values in a hash.

Time complexity: O(N), where N is the total number of entries
[中]返回散列中的所有字段和关联值。
时间复杂度:O(N),其中N是条目的总数

代码示例

代码示例来源:origin: apache/storm

@Override
public Map<byte[], byte[]> hgetAll(byte[] key) {
  return jedis.hgetAll(key);
}

代码示例来源:origin: apache/storm

@Override
public Map<String, String> hgetAll(String key) {
  return jedis.hgetAll(key);
}

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

@Override
 public Map<byte[], byte[]> execute(Jedis connection) {
  return connection.hgetAll(key);
 }
}.runBinary(key);

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

@Override
 public Map<String, String> execute(Jedis connection) {
  return connection.hgetAll(key);
 }
}.run(key);

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

public Map<byte[], byte[]> execute(Jedis connection) {
    return connection.hgetAll(keyByte);
  }
}.runBinary(keyByte);

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

@Override
public Map<byte[], byte[]> hgetAll(byte[] key) {
 Jedis j = getShard(key);
 return j.hgetAll(key);
}

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

@Override
public Map<String, String> hgetAll(String key) {
 Jedis j = getShard(key);
 return j.hgetAll(key);
}

代码示例来源:origin: changmingxie/tcc-transaction

@Override
  public Map<byte[], byte[]> doInJedis(Jedis jedis) {
    return jedis.hgetAll(RedisHelper.getRedisKey(keyPrefix, xid));
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
protected void command() {
  jedis.select(db);
  value = jedis.hgetAll(key);
  
}

代码示例来源:origin: apache/incubator-dubbo

private void clean(Jedis jedis) {
  Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
  if (CollectionUtils.isNotEmpty(keys)) {
    for (String key : keys) {
      Map<String, String> values = jedis.hgetAll(key);
      if (CollectionUtils.isNotEmptyMap(values)) {
        boolean delete = false;
        long now = System.currentTimeMillis();
        for (Map.Entry<String, String> entry : values.entrySet()) {
          URL url = URL.valueOf(entry.getKey());
          if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
            long expire = Long.parseLong(entry.getValue());
            if (expire < now) {
              jedis.hdel(key, entry.getKey());
              delete = true;
              if (logger.isWarnEnabled()) {
                logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
              }
            }
          }
        }
        if (delete) {
          jedis.publish(key, Constants.UNREGISTER);
        }
      }
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

private void clean(Jedis jedis) {
  Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
  if (CollectionUtils.isNotEmpty(keys)) {
    for (String key : keys) {
      Map<String, String> values = jedis.hgetAll(key);
      if (CollectionUtils.isNotEmptyMap(values)) {
        boolean delete = false;
        long now = System.currentTimeMillis();
        for (Map.Entry<String, String> entry : values.entrySet()) {
          URL url = URL.valueOf(entry.getKey());
          if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
            long expire = Long.parseLong(entry.getValue());
            if (expire < now) {
              jedis.hdel(key, entry.getKey());
              delete = true;
              if (logger.isWarnEnabled()) {
                logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
              }
            }
          }
        }
        if (delete) {
          jedis.publish(key, Constants.UNREGISTER);
        }
      }
    }
  }
}

代码示例来源:origin: Netflix/conductor

@Override
public Map<String, String> hgetAll(String key) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.hgetAll(key);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: jfinal/jfinal

/**
 * 返回哈希表 key 中,所有的域和值。
 * 在返回值里,紧跟每个域名(field name)之后是域的值(value),所以返回值的长度是哈希表大小的两倍。
 */
@SuppressWarnings("rawtypes")
public Map hgetAll(Object key) {
  Jedis jedis = getJedis();
  try {
    Map<byte[], byte[]> data = jedis.hgetAll(keyToBytes(key));
    Map<Object, Object> result = new HashMap<Object, Object>();
    for (Entry<byte[], byte[]> e : data.entrySet())
      result.put(fieldFromBytes(e.getKey()), valueFromBytes(e.getValue()));
    return result;
  }
  finally {close(jedis);}
}

代码示例来源:origin: apache/incubator-dubbo

Map<String, String> values = jedis.hgetAll(key);
if (CollectionUtils.isNotEmptyMap(values)) {
  for (Map.Entry<String, String> entry : values.entrySet()) {

代码示例来源:origin: apache/incubator-dubbo

Map<String, String> values = jedis.hgetAll(key);
if (CollectionUtils.isNotEmptyMap(values)) {
  for (Map.Entry<String, String> entry : values.entrySet()) {

代码示例来源:origin: prestodb/presto

valueMap = jedis.hgetAll(keyString);
if (valueMap == null) {
  log.warn("Redis data modified while query was running, hash value at key %s deleted", keyString);

代码示例来源:origin: ltsopensource/light-task-scheduler

Map<String, String> values = jedis.hgetAll(key);
List<String> currentChildren = values == null ? new ArrayList<String>(0) : new ArrayList<String>(values.keySet());
List<String> oldChildren = reload ? null : cachedNodeMap.get(key);

代码示例来源:origin: jooby-project/jooby

@Override
public Session get(final Builder builder) {
 Jedis jedis = null;
 try {
  jedis = pool.getResource();
  String key = key(builder.sessionId());
  Map<String, String> attrs = jedis.hgetAll(key);
  if (attrs == null || attrs.size() == 0) {
   // expired
   return null;
  }
  if (timeout > 0) {
   // touch session
   jedis.expire(key, timeout);
  }
  return builder
    .accessedAt(Long.parseLong(attrs.remove("_accessedAt")))
    .createdAt(Long.parseLong(attrs.remove("_createdAt")))
    .savedAt(Long.parseLong(attrs.remove("_savedAt")))
    .set(attrs)
    .build();
 } finally {
  if (jedis != null) {
   jedis.close();
  }
 }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

if (CollectionUtils.isNotEmpty(nodePaths)) {
  for (String nodePath : nodePaths) {
    Map<String, String> nodes = jedis.hgetAll(nodePath);
    if (CollectionUtils.isNotEmpty(nodes)) {
      boolean delete = false;

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

@Override
public Map<byte[], byte[]> hGetAll(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().hgetAll(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().hgetAll(key)));
      return null;
    }
    return connection.getJedis().hgetAll(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

相关文章

Jedis类方法