本文整理汇总了Java中redis.clients.jedis.Jedis.scard方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.scard方法的具体用法?Java Jedis.scard怎么用?Java Jedis.scard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.scard方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scardString
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
* 返回集合key的基数(集合中元素的数量)。
*
* @param key
* @return
*/
public long scardString(String key) {
Jedis jedis = null;
boolean success = true;
long ret = 0L;
try {
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return ret;
}
ret = jedis.scard(key);
} catch (Exception e) {
success = false;
returnBrokenResource(jedis, "scardString" + key, e);
System.out.println(e.getMessage().toString());
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例2: getLenBySet
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
* 获取Set长度
* @param setKey
* @return
*/
public Long getLenBySet(String setKey) throws Exception {
Jedis jds = null;
try {
jds = getJedis();
jds.select(0);
Long result = jds.scard(setKey);
return result;
} catch (Exception e) {
throw e;
} finally {
if(jds != null)
{
jds.close();
}
}
}
示例3: getTotalCount
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public int getTotalCount(Task task) {
Jedis jedis = jedisPool.getResource();
try {
Long size = jedis.scard(RedisKeys.getSetKey(task));
return size.intValue();
} finally {
jedis.close();
}
}
示例4: getTotalRequests
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public int getTotalRequests(String spiderName) {
Jedis jedis = pool.getResource();
try {
Long size = jedis.scard(getSetKey(spiderName));
return size.intValue();
} finally {
pool.returnResource(jedis);
}
}
示例5: scard
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Long scard(String key) {
Jedis jedis = null;
Long res = null;
try {
jedis = pool.getResource();
res = jedis.scard(key);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}
示例6: getTotalRequestsCount
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public int getTotalRequestsCount(ISpider spider) {
Jedis jedis = pool.getResource();
try {
Long size = jedis.scard(getSetKey(spider));
return size.intValue();
} finally {
jedis.close();
}
}