本文整理了Java中redis.clients.jedis.Jedis.zcard()
方法的一些代码示例,展示了Jedis.zcard()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.zcard()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:zcard
[英]Return the sorted set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sorted sets.
Time complexity O(1)
[中]返回已排序的集合基数(元素数)。如果键不存在,则返回0,如空排序集。
时间复杂度O(1)
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.zcard(key);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long execute(Jedis connection) {
return connection.zcard(key);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Long zcard(String key) {
Jedis j = getShard(key);
return j.zcard(key);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public Long zcard(byte[] key) {
Jedis j = getShard(key);
return j.zcard(key);
}
代码示例来源:origin: Netflix/conductor
@Override
public Long zcard(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.zcard(key);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: caoxinyu/RedisClient
protected long getSize(String key) {
Long size;
String type = jedis.type(key);
if (type.equals("string"))
size = (long) 1;
else if (type.equals("hash"))
size = jedis.hlen(key);
else if (type.equals("list"))
size = jedis.llen(key);
else if (type.equals("set"))
size = jedis.scard(key);
else
size = jedis.zcard(key);
return size;
}
代码示例来源:origin: jfinal/jfinal
/**
* 返回有序集 key 的基数。
*/
public Long zcard(Object key) {
Jedis jedis = getJedis();
try {
return jedis.zcard(keyToBytes(key));
}
finally {close(jedis);}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long zCard(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zcard(key)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().zcard(key)));
return null;
}
return connection.getJedis().zcard(key);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: yrain/smart-cache
@Override
Long doInJedis(Jedis jedis) {
return jedis.zcard(key);
}
});
代码示例来源:origin: yrain/smart-cache
@Override
Long doInJedis(Jedis jedis) {
return jedis.zcard(key);
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long execute(Jedis connection) {
return connection.zcard(key);
}
}.runBinary(key);
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
return jedis.zcard(key);
}
});
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long zcard(byte[] key) {
String command = "zcard";
return instrumented(command, () -> delegated.zcard(key));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Long zcard(String key) {
String command = "zcard";
return instrumented(command, () -> delegated.zcard(key));
}
代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence
@Override
public Long zcard(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.zcard(key);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: gresrun/jesque
protected KeyInfo handleZSet(final Jedis jedis) {
final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.ZSET);
keyInfo.setSize(jedis.zcard(this.key));
if (this.doArrayValue) {
keyInfo.setArrayValue(new ArrayList<String>(
jedis.zrange(this.key, this.offset, this.offset + this.count)));
}
return keyInfo;
}
代码示例来源:origin: yangfuhai/jboot
/**
* 返回有序集 key 的基数。
*/
public Long zcard(Object key) {
Jedis jedis = getJedis();
try {
return jedis.zcard(keyToBytes(key));
} finally {
returnResource(jedis);
}
}
代码示例来源:origin: xetorthio/johm
public Long zcard() {
Jedis jedis = getResource();
Long zadd = jedis.zcard(key());
returnResource(jedis);
return zadd;
}
代码示例来源:origin: com.jfinal/jfinal
/**
* 返回有序集 key 的基数。
*/
public Long zcard(Object key) {
Jedis jedis = getJedis();
try {
return jedis.zcard(keyToBytes(key));
}
finally {close(jedis);}
}
代码示例来源:origin: xiancloud/xian
@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
String key = msg.get("key", String.class);
CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
try {
Long length = Redis.call(cacheConfigBean, jedis -> jedis.zcard(key));
handler.handle(UnitResponse.createSuccess(length));
} catch (Throwable e) {
handler.handle(UnitResponse.createException(e));
}
}
内容来源于网络,如有侵权,请联系作者删除!