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

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

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

JedisCluster.hmget介绍

暂无

代码示例

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

@Override
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(fields, "Fields must not be null!");
  try {
    return connection.getCluster().hmget(key, fields);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
protected List<String> retrieveValuesFromRedis(List<String> keys) {
  String[] stringKeys = keys.toArray(new String[keys.size()]);
  RedisDataTypeDescription description = this.options.dataTypeDescription;
  switch (description.getDataType()) {
    case STRING:
      List<String> values = Lists.newArrayList();
      for (String stringKey : keys) {
        String value = jedisCluster.get(stringKey);
        values.add(value);
      }
      return values;
    case HASH:
      return jedisCluster.hmget(description.getAdditionalKey(), stringKeys);
    default:
      throw new IllegalArgumentException("Cannot process such data type: " + description.getDataType());
  }
}

代码示例来源:origin: net.oschina.j2cache/j2cache-core

@Override
public List<byte[]> hmget(byte[] bytes, byte[]... bytes1) {
  return cluster.hmget(bytes, bytes1);
}

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

public List<String> hmget(String key, String... fields) {
  return jedisCluster.hmget(key, fields);
}

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

public List<byte[]> hmget(byte[] key, byte[]... fields) {
  return jedisCluster.hmget(key, fields);
}

代码示例来源:origin: hhfcyong/xxxx-dubbo

/**
 * 返回哈希表 key 中,一个或多个给定域的值
 * 如果给定的域不存在于哈希表,那么返回一个 nil 值
 * 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表
 * @param key  
 * @param fields 格式为:field,field,field........
 * @return 一个包含多个给定域的关联值的表,表值的排列顺序和给定域参数的请求顺序一样
 */
public List<String> hmget(String key,String fields){
  String[] field=fields.split(",");
  return jedisCluster.hmget(key, field);
}
/**

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(fields, "Fields must not be null!");
  try {
    return connection.getCluster().hmget(key, fields);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(fields, "Fields must not be null!");
  try {
    return connection.getCluster().hmget(key, fields);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: org.nanoframework/nano-orm-jedis

@Override
public Map<String, String> hmget(final String key, final String... fields) {
  Assert.hasText(key);
  Assert.notEmpty(fields);
  try {
    final List<String> values = cluster.hmget(key, fields);
    final Map<String, String> valuesMap = Maps.newHashMap();
    for (int idx = 0; idx < values.size(); idx++) {
      final String value = values.get(idx);
      if (value != null) {
        valuesMap.put(fields[idx], value);
      }
    }
    return valuesMap;
  } catch (final Throwable e) {
    throw new RedisClientException(e.getMessage(), e);
  }
}

代码示例来源:origin: yangfuhai/jboot

/**
 * 返回哈希表 key 中,一个或多个给定域的值。
 * 如果给定的域不存在于哈希表,那么返回一个 nil 值。
 * 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表。
 */
@SuppressWarnings("rawtypes")
public List hmget(Object key, Object... fields) {
  List<byte[]> data = jedisCluster.hmget(keyToBytes(key), valuesToBytesArray(fields));
  return valueListFromBytesList(data);
}

代码示例来源:origin: yrain/smart-cache

/**
 * 根据key和field,同时获取多个值
 */
@SuppressWarnings("unchecked")
public <E> List<E> hmget(Object key, Object... fields) {
  if (null == key) {
    return null;
  }
  List<E> objs = Lists.newArrayList();
  if (fields.length <= 0) {
    fields = hkeys(key).toArray();
  }
  List<byte[]> bytes = null;
  if (cluster) {
    bytes = jedisCluster.hmget(serializeKey(key), convertObjectArrayToByteArray_serializeKey(fields));
  } else {
    bytes = jedisOperator.hmget(serializeKey(key), convertObjectArrayToByteArray_serializeKey(fields));
  }
  for (byte[] bs : bytes) {
    objs.add((E) deserializeVal(bs));
  }
  return objs;
}

相关文章

微信公众号

最新文章

更多

JedisCluster类方法