本文整理汇总了Java中redis.clients.jedis.Jedis.hmget方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.hmget方法的具体用法?Java Jedis.hmget怎么用?Java Jedis.hmget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.hmget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVByMap
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
*
* @param <T>
* @param mapkey map
* @param key map里的key
* @param requiredType value的泛型类型
* @return
*/
@SuppressWarnings("unchecked")
public <T> T getVByMap(String mapkey,String key , Class<T> requiredType) throws Exception {
Jedis jds = null;
try {
jds = getJedis();
jds.select(0);
List<byte[]> result = jds.hmget(mapkey.getBytes(), key.getBytes());
if(null != result && result.size() > 0 ){
byte[] x = result.get(0);
T resultObj = SerializeUtil.deserialize(x, requiredType);
return resultObj;
}
} catch (Exception e) {
throw e;
} finally {
if(jds != null)
{
jds.close();
}
}
return null;
}
示例2: timeoutConnection
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test(expected = JedisConnectionException.class)
public void timeoutConnection() throws Exception {
jedis = new Jedis("localhost", 6379, 15000);
jedis.auth("foobared");
jedis.configSet("timeout", "1");
Thread.sleep(2000);
jedis.hmget("foobar", "foo");
}
示例3: timeoutConnectionWithURI
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test(expected = JedisConnectionException.class)
public void timeoutConnectionWithURI() throws Exception {
jedis = new Jedis(new URI("redis://:[email protected]:6380/2"), 15000);
jedis.configSet("timeout", "1");
Thread.sleep(2000);
jedis.hmget("foobar", "foo");
}
示例4: hmget
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public List<String> hmget(String key, String... fields) {
Jedis jedis = null;
List<String> res = null;
try {
jedis = pool.getResource();
res = jedis.hmget(key, fields);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}
示例5: getCache
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public List<String> getCache(String key, String... fields) {
Jedis jedis = null;
List var4;
try {
jedis = pool.getResource();
var4 = jedis.hmget(key, fields);
} catch (Exception var8) {
throw new RuntimeException(var8);
} finally {
pool.returnResourceObject(jedis);
}
return var4;
}