本文整理了Java中redis.clients.jedis.Jedis.hmget()
方法的一些代码示例,展示了Jedis.hmget()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.hmget()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:hmget
[英]Retrieve the values associated to the specified fields.
If some of the specified fields do not exist, nil values are returned. Non existing keys are considered like empty hashes.
Time complexity: O(N) (with N being the number of fields)
[中]检索与指定字段关联的值。
如果某些指定字段不存在,则返回nil值。不存在的键被视为空哈希。
时间复杂度:O(N)(N为字段数)
代码示例来源:origin: sohutv/cachecloud
@Override
public List<String> execute(Jedis connection) {
return connection.hmget(key, fields);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public List<byte[]> execute(Jedis connection) {
return connection.hmget(key, fields);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
public List<byte[]> execute(Jedis connection) {
return connection.hmget(keyByte, fields);
}
}.runBinary(keyByte);
代码示例来源:origin: sohutv/cachecloud
@Override
public List<String> hmget(String key, String... fields) {
Jedis j = getShard(key);
return j.hmget(key, fields);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public List<byte[]> hmget(byte[] key, byte[]... fields) {
Jedis j = getShard(key);
return j.hmget(key, fields);
}
代码示例来源:origin: Netflix/conductor
@Override
public List<String> hmget(String key, String... fields) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.hmget(key, fields);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: apache/storm
/**
* {@inheritDoc}
*/
@Override
protected List<String> retrieveValuesFromRedis(RedisState state, List<String> keys) {
Jedis jedis = null;
try {
jedis = state.getJedis();
List<String> redisVals;
String[] keysForRedis = keys.toArray(new String[keys.size()]);
switch (dataType) {
case STRING:
redisVals = jedis.mget(keysForRedis);
break;
case HASH:
redisVals = jedis.hmget(additionalKey, keysForRedis);
break;
default:
throw new IllegalArgumentException("Cannot process such data type: " + dataType);
}
return redisVals;
} finally {
if (jedis != null) {
state.returnJedis(jedis);
}
}
}
}
代码示例来源:origin: apache/storm
/**
* {@inheritDoc}
*/
@Override
protected List<String> retrieveValuesFromRedis(List<String> keys) {
String[] stringKeys = keys.toArray(new String[keys.size()]);
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
RedisDataTypeDescription description = this.options.dataTypeDescription;
switch (description.getDataType()) {
case STRING:
return jedis.mget(stringKeys);
case HASH:
return jedis.hmget(description.getAdditionalKey(), stringKeys);
default:
throw new IllegalArgumentException("Cannot process such data type: " + description.getDataType());
}
} finally {
if (jedis != null) {
jedis.close();
}
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 返回哈希表 key 中,一个或多个给定域的值。
* 如果给定的域不存在于哈希表,那么返回一个 nil 值。
* 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表。
*/
@SuppressWarnings("rawtypes")
public List hmget(Object key, Object... fields) {
Jedis jedis = getJedis();
try {
List<byte[]> data = jedis.hmget(keyToBytes(key), fieldsToBytesArray(fields));
return valueListFromBytesList(data);
}
finally {close(jedis);}
}
代码示例来源: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 {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hmget(key, fields)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().hmget(key, fields)));
return null;
}
return connection.getJedis().hmget(key, fields);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: Impetus/Kundera
columnValues = ((Jedis) connection).hmget(hashKey, columnName);
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
return jedis.hmget(key, fields);
}
});
代码示例来源:origin: com.github.sogyf/goja-mvt
@Override
public List<String> action(Jedis jedis) {
return jedis.hmget(key, fields);
}
});
代码示例来源:origin: Impetus/Kundera
fieldValues = ((Jedis) connection).hmget(getEncodedBytes(hashKey), fields);
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public List<String> hmget(String key, String... fields) {
String command = "hmget";
return instrumented(command, () -> delegated.hmget(key, fields));
}
代码示例来源:origin: stackoverflow.com
int fromMinute = 1;
int toMinute = 10;
List<String> list = new ArrayList<String>();
for(int i = fromMinute ; i < toMinute ; i++) {
list.add(i.toString());
}
Jedis jedis = new Jedis("localhost");
List<String> values = jedis.hmget("your_set_name", list);
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public List<byte[]> hmget(byte[] key, byte[]... fields) {
String command = "hmget";
return instrumented(command, () -> delegated.hmget(key, fields));
}
代码示例来源:origin: org.leapframework/jmms-modules-redis
/**
* Get the values of all the given hash fields.
*/
public Result<List<String>> hmget(String key, String... fields) {
return exec(redis -> redis.hmget(key));
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
public long getEstimatedCount(T element) {
try (Jedis jedis = pool.allowingSlaves().getResource()) {
byte[][] hashesString = RedisUtils.encodeKey(hash(toBytes(element)));
List<byte[]> hmget = jedis.hmget(keys.COUNTS_KEY.getBytes(), hashesString);
return hmget.stream().mapToLong(i -> (i == null) ? 0L : RedisUtils.decodeValue(i)).min().orElse(0L);
}
}
代码示例来源:origin: io.enoa/nosql-redis
default <T> List<T> hmget(String key, String... fields) {
return this.run((jedis, serializer) ->
EnoaRedisConvert.with(serializer).<T>convertList(jedis.hmget(SafeEncoder.encode(key),
EnoaRedisConvert.with(serializer).toBytesKeys(fields))));
}
内容来源于网络,如有侵权,请联系作者删除!