@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); } }
/** * {@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()); } }
@Override public List<byte[]> hmget(byte[] bytes, byte[]... bytes1) { return cluster.hmget(bytes, bytes1); }
public List<String> hmget(String key, String... fields) { return jedisCluster.hmget(key, fields); }
public List<byte[]> hmget(byte[] key, byte[]... fields) { return jedisCluster.hmget(key, fields); }
/** * 返回哈希表 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); } /**
@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); } }
@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); } }
@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); } }
/** * 返回哈希表 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); }
/** * 根据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; }