本文整理匯總了Java中redis.clients.jedis.ShardedJedis.hget方法的典型用法代碼示例。如果您正苦於以下問題:Java ShardedJedis.hget方法的具體用法?Java ShardedJedis.hget怎麽用?Java ShardedJedis.hget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.ShardedJedis
的用法示例。
在下文中一共展示了ShardedJedis.hget方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hgetValueOfObject
import redis.clients.jedis.ShardedJedis; //導入方法依賴的package包/類
/**
* 從Hash中獲取對象,轉換成製定類型
*/
@Override
public <T> T hgetValueOfObject(String key, String field, Class<T> clazz) {
ShardedJedis redis = null;
T t = null;
try {
redis = pool.getResource();
key = getKeyAll(key);
String value = redis.hget(key, field);
if (value == null) {
return null;
}
t = JsonEntityTransform.json2Object(value, clazz);
return t;
} catch (RuntimeException e) {
if(redis != null ) {
pool.returnBrokenResource(redis);
}
logger.error("redis hgetValueOfObject(String key, String field, Class<T> clazz):", e);
return t;
} finally{
if(redis != null ) {
pool.returnResource(redis);
}
}
}
示例2: hget
import redis.clients.jedis.ShardedJedis; //導入方法依賴的package包/類
@Override
public String hget(String key, String field) {
ShardedJedis redis = null;
String result = null;
try {
redis = pool.getResource();
key = getKeyAll(key);
result = redis.hget(key, field);
return result;
} catch (RuntimeException e) {
if(redis != null ) {
pool.returnBrokenResource(redis);
}
logger.error("redis hget(String key, String field):", e);
return result;
} finally{
if(redis != null ) {
pool.returnResource(redis);
}
}
}
示例3: hgetValueOfList
import redis.clients.jedis.ShardedJedis; //導入方法依賴的package包/類
/**
* 從Hash中獲取對象,轉換成製定類型
*/
@Override
public <T> List<T> hgetValueOfList(String key, String field, Class<T> clazz) {
ShardedJedis redis = null;
List<T> entitys = null;
try {
redis = pool.getResource();
key = getKeyAll(key);
String value = redis.hget(key, field);
if (value == null) {
return null;
}
entitys = JsonEntityTransform.json2ObjectList(value, clazz);
return entitys;
} catch (RuntimeException e) {
if(redis != null ) {
pool.returnBrokenResource(redis);
}
logger.error("redis hgetValueOfList(String key, String field, Class<T> clazz):", e);
return entitys;
} finally{
if(redis != null ) {
pool.returnResource(redis);
}
}
}
示例4: hgetValueOfEntity
import redis.clients.jedis.ShardedJedis; //導入方法依賴的package包/類
/**
* 從Hash中獲取對象,轉換成製定類型
*/
@Override
public <T extends BaseEntity> T hgetValueOfEntity(String key, String field,
Class<T> clazz) {
ShardedJedis redis = null;
T entity = null;
try {
redis = pool.getResource();
key = getKeyAll(key);
String value = redis.hget(key, field);
if (value == null) {
return null;
}
entity = JsonEntityTransform.json2Entity(value, clazz);
return entity;
} catch (RuntimeException e) {
if(redis != null ) {
pool.returnBrokenResource(redis);
}
logger.error("redis hgetValueOfEntity(String key, String field,Class<T> clazz):", e);
return entity;
} finally{
if(redis != null ) {
pool.returnResource(redis);
}
}
}