本文整理汇总了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);
}
}
}