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

The following examples show how to use redis.clients.jedis.Jedis#zcard() . 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: JedisUtil.java    From newblog with Apache License 2.0 6 votes vote down vote up
public Long zcard(String key) {
    Jedis jedis = null;
    try {
        jedis = getJedis();
        if (jedis == null) {
            logger.error("get jedis fail");
            return null;
        }
        return jedis.zcard(key);
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
        }
    } finally {
        returnJedisResource(jedis);
    }
    return null;
}
 
Example 2
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * 通过key返回zset中的value个数
 * </p>
 *
 * @param key
 * @return
 */
public Long zcard(String key) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.zcard(key);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 3
Source File: JedisUtil.java    From scaffold-cloud with MIT License 5 votes vote down vote up
/**
 * 查询集合成员数量
 *
 * @param key
 * @return sortedset 的成员数量
 */
public static Long zcard(String key) {
    Long result = null;
    Jedis jedis = null;
    try {
        jedis = getResource();
        result = jedis.zcard(key);
    } catch (Exception e) {
        logger.warn("zcard {} = {}", key, e);
    } finally {
        close(jedis);
    }
    return result;
}
 
Example 4
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public Long zcard(String key) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = pool.getResource();
        res = jedis.zcard(key);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 5
Source File: JedisBlockingQueueStore.java    From vscrawler with Apache License 2.0 5 votes vote down vote up
@Override
public long size(String queueID) {
    Jedis jedis = jedisPool.getResource();
    try {
        return jedis.zcard(makePoolQueueKey(queueID));
    } finally {
        IOUtils.closeQuietly(jedis);
    }
}
 
Example 6
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 获取集合中元素的数量
 * 
 * @param String
 *            key
 * @return 如果返回0则集合不存在
 * */
public long zcard(String key) {
	// ShardedJedis sjedis = getShardedJedis();
	Jedis sjedis = getJedis();
	long len = sjedis.zcard(key);
	returnJedis(sjedis);
	return len;
}
 
Example 7
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long zcard0(Jedis j, String key) {
	return j.zcard(key);
}