Java Code Examples for redis.clients.jedis.Jedis#hvals()

The following examples show how to use redis.clients.jedis.Jedis#hvals() . 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: JedisCacheManager.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Collection<V> values() {
	Collection<V> vals = Collections.emptyList();;
	Jedis jedis = null;
	try {
		jedis = jedisAgent.getResource();
		Collection<byte[]> col = jedis.hvals(JedisUtils.getBytesKey(cacheKeyName));
		for(byte[] val : col){
			Object obj = JedisUtils.toObject(val);
			if (obj != null){
				vals.add((V) obj);
			}
       	}
		logger.debug("values {} {} ", cacheKeyName, vals);
		return vals;
	} catch (Exception e) {
		logger.error("values {}",  cacheKeyName, e);
	} finally {
		Streams.safeClose(jedis);
	}
	return vals;
}
 
Example 2
Source File: JedisCacheManager.java    From easyweb with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Collection<V> values() {
	Collection<V> vals = Collections.emptyList();;
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		Collection<byte[]> col = jedis.hvals(JedisUtils.getBytesKey(cacheKeyName));
		for(byte[] val : col){
			Object obj = JedisUtils.toObject(val);
			if (obj != null){
				vals.add((V) obj);
			}
       	}
		logger.debug("values {} {} ", cacheKeyName, vals);
		return vals;
	} catch (Exception e) {
		logger.error("values {}",  cacheKeyName, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return vals;
}
 
Example 3
Source File: JedisCacheManager.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Collection<V> values() {
	Collection<V> vals = Collections.emptyList();;
	Jedis jedis = null;
	try {
		jedis = JedisUtils.getResource();
		Collection<byte[]> col = jedis.hvals(JedisUtils.getBytesKey(cacheKeyName));
		for(byte[] val : col){
			vals.add((V)val);
       	}
		logger.debug("values {} {} ", cacheKeyName, vals);
		return vals;
	} catch (Exception e) {
		logger.error("values {}",  cacheKeyName, e);
	} finally {
		JedisUtils.returnResource(jedis);
	}
	return vals;
}
 
Example 4
Source File: RedisClient.java    From apollo with GNU General Public License v2.0 6 votes vote down vote up
public List<Object> hValues(String key) throws Exception {
    Jedis jedis = null;
    try {
        jedis = this.jedisPool.getResource();
        List<byte[]> hvals = jedis.hvals(SafeEncoder.encode(key));
        logger.info("hvals key:" + key);
        if (CollectionUtils.isEmpty(hvals)) {
            return new ArrayList<Object>(1);
        } else {
            List<Object> ret = new ArrayList<Object>(hvals.size());
            for (byte[] bb : hvals) {
                ret.add(deserialize(bb));
            }
            return ret;
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        this.jedisPool.returnBrokenResource(jedis);
        throw e;
    } finally {
        if (jedis != null) {
            this.jedisPool.returnResource(jedis);
        }
    }
}
 
Example 5
Source File: JedisClientPool.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> hvals(String key) {
	Jedis jedis = jedisPool.getResource();
	List<String> result = jedis.hvals(key);
	jedis.close();
	return result;
}
 
Example 6
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * 通过key返回所有和key有关的value
 * </p>
 *
 * @param key
 * @return
 */
public List<String> hvals(String key) {
    Jedis jedis = null;
    List<String> res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.hvals(key);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 7
Source File: JedisUtil.java    From scaffold-cloud with MIT License 5 votes vote down vote up
/**
 * 取得hash的values
 *
 * @param key
 * @return
 */
public static List<byte[]> hvals(final String key) {
    Jedis jedis = null;
    List<byte[]> result = null;
    try {
        jedis = getResource();
        result = jedis.hvals(getBytesKey(key));
    } finally {
        close(jedis);
    }
    return result;
}
 
Example 8
Source File: JedisUtil.java    From Project with Apache License 2.0 5 votes vote down vote up
/**
 * 获取hash中value的集合
 * 
 * @param  key
 * @return List<String>
 */
public List<String> hvals(String key) {
	Jedis sjedis = getJedis();
	List<String> list = sjedis.hvals(key);
	sjedis.close();
	return list;
}
 
Example 9
Source File: JedisClientPool.java    From express-ssm with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> hvals(String key) {
    Jedis jedis = jedisPool.getResource();
    List<String> result = jedis.hvals(key);
    jedis.close();
    return result;
}
 
Example 10
Source File: JedisClientPool.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> hvals(String key) {
    Jedis jedis = jedisPool.getResource();
    List<String> result = jedis.hvals(key);
    jedis.close();
    return result;
}
 
Example 11
Source File: RedisClient.java    From Mykit with Apache License 2.0 5 votes vote down vote up
public List<String> hvals(String key) {
	Jedis client = jedisPool.getResource();
	try {
		List<String> values = client.hvals(key);
		return values;
	} finally {
		// 向连接池“归还”资源
		jedisPool.returnResourceObject(client);
	}

}
 
Example 12
Source File: JedisClientPool.java    From paas with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> hvals(String key) {
    Jedis jedis = jedisPool.getResource();
    List<String> result = jedis.hvals(key);
    jedis.close();
    return result;
}
 
Example 13
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> hvals(String key) {
    Jedis jedis = null;
    List<String> res = null;
    try {
        jedis = pool.getResource();
        res = jedis.hvals(key);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 14
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 获取hash中value的集合
 * 
 * @param String
 *            key
 * @return List<String>
 * */
public List<String> hvals(String key) {
	// ShardedJedis sjedis = getShardedJedis();
	Jedis sjedis = getJedis();
	List<String> list = sjedis.hvals(key);
	returnJedis(sjedis);
	return list;
}
 
Example 15
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private List<String> hvals0(Jedis j, String key) {
	return j.hvals(key);
}