本文整理匯總了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;
}