Java Code Examples for redis.clients.jedis.ShardedJedis#hgetAll()

The following examples show how to use redis.clients.jedis.ShardedJedis#hgetAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisCacheClient.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * 通过hash key获取所有对象
 * @param key
 * @param clazz
 * @param <T>
 * @return
 */
public <T> Map<String, T> hgetAll(String key, Class<T> clazz) {
	ShardedJedis redis = null;
	Map<String, T> map = new HashMap<>();
	try {
		redis = pool.getResource();
		key = getKeyAll(key);
		Map<String, String> result = redis.hgetAll(key);
		if (!Check.NuNMap(result)) {
			for (String mapKey : result.keySet()) {
				map.put(mapKey, JsonEntityTransform.json2Object(result.get(mapKey), clazz));
			}
		}
		return map;
	} catch (RuntimeException e) {
		if(redis != null ) {
			pool.returnBrokenResource(redis);
		}
		logger.error("redis hegeAll(String key):", e);
		return map;
	} finally{
		if(redis != null ) {
			pool.returnResource(redis);
		}
	}
}
 
Example 2
Source File: MarsRedisTemplate.java    From Mars-Java with MIT License 5 votes vote down vote up
/**
 * 获取一组数据
 * @param group
 * @return
 */
public Map<String, String> hgetAll(String group){
    ShardedJedis jedis = null;
    Map<String, String>  result = null;
    try {
        jedis = getShardedJedis();
        result = jedis.hgetAll(group);
    } catch (Exception e) {
        logger.error("hgetAll redis value error:" + group, e);
    } finally {
        recycleJedis(jedis);
    }

    return result;
}
 
Example 3
Source File: RedisServiceImpl.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
@Override
public <T> T hgetAll(final String key, final Callback<T> callback) {
	checkParameters(key, callback);

	final ShardedJedis jedis = getJedis();
	final Map<String, String> result = jedis.hgetAll(key);
	try {
		return callback.callback(result);
	} catch (final Exception e) {
		throw new GetValueRedisException("method: hgetAll, key: " + key + ", result: " + result, e);
	} finally {
		returnResource(jedis);
	}
}
 
Example 4
Source File: ShardedRedisCache.java    From framework with Apache License 2.0 5 votes vote down vote up
/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param node
 * @return <br>
 */
@Override
protected Map<byte[], byte[]> getNode(final byte[] node) {
    ShardedJedis shardedJedis = null;
    try {
        shardedJedis = shardedPool.getResource();
        return shardedJedis.hgetAll(node);
    }
    finally {
        if (shardedJedis != null) {
            shardedJedis.close();
        }
    }
}
 
Example 5
Source File: RedisClientImpl.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> hgetAll(final String key) {
    Assert.hasText(key);

    ShardedJedis jedis = null;
    try {
        jedis = POOL.getJedis(config.getRedisType());
        return jedis.hgetAll(key);
    } catch (final Throwable e) {
        throw new RedisClientException(e.getMessage(), e);
    } finally {
        POOL.close(jedis);
    }
}