redis.clients.jedis.Jedis.scard()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中redis.clients.jedis.Jedis.scard()方法的一些代码示例,展示了Jedis.scard()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.scard()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:scard

Jedis.scard介绍

[英]Return the set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sets.
[中]返回集合基数(元素数)。如果密钥不存在,则返回0,如空集。

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public Long execute(Jedis connection) {
  return connection.scard(key);
 }
}.runBinary(key);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Long execute(Jedis connection) {
  return connection.scard(key);
 }
}.run(key);

代码示例来源:origin: sohutv/cachecloud

@Override
public Long scard(byte[] key) {
 Jedis j = getShard(key);
 return j.scard(key);
}

代码示例来源:origin: sohutv/cachecloud

@Override
public Long scard(String key) {
 Jedis j = getShard(key);
 return j.scard(key);
}

代码示例来源:origin: code4craft/webmagic

@Override
  public int getTotalRequestsCount(Task task) {
    Jedis jedis = pool.getResource();
    try {
      Long size = jedis.scard(getSetKey(task));
      return size.intValue();
    } finally {
      pool.returnResource(jedis);
    }
  }
}

代码示例来源:origin: Netflix/conductor

@Override
public Long scard(String key) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.scard(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 scard(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.scard(keyToBytes(key));
  }
  finally {close(jedis);}
}

代码示例来源:origin: shuzheng/zheng

LOGGER.debug("当前code={},对应的注册系统个数:{}个", code, RedisUtil.getJedis().scard(ZHENG_UPMS_CLIENT_SESSION_IDS + "_" + code));

代码示例来源:origin: shuzheng/zheng

jedis.srem(ZHENG_UPMS_CLIENT_SESSION_IDS + "_" + code, clientSessionId);
LOGGER.debug("当前code={},对应的注册系统个数:{}个", code, jedis.scard(ZHENG_UPMS_CLIENT_SESSION_IDS + "_" + code));
jedis.close();

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long sCard(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().scard(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().scard(key)));
      return null;
    }
    return connection.getJedis().scard(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: jwpttcg66/NettyGameServer

/**
 * 返回集合key的基数(集合中元素的数量)。
 * @param key
 * @return
 */
public long scardString(String key){
  Jedis jedis = null;
  boolean sucess = true;
  long rt = 0L;
  try {
    jedis = jedisPool.getResource();
    rt = jedis.scard(key);
  } catch (Exception e) {
    sucess = false;
    returnBrokenResource(jedis, "scardString"+key, e);
  } finally {
    if (sucess && jedis != null) {
      returnResource(jedis);
    }
  }
  return rt;
}

代码示例来源:origin: apache/servicemix-bundles

@Override
 public Long execute(Jedis connection) {
  return connection.scard(key);
 }
}.runBinary(key);

代码示例来源:origin: gresrun/jesque

/**
   * {@inheritDoc}
   */
  @Override
  public Long doWork(final Jedis jedis) throws Exception {
    return jedis.scard(key(WORKERS));
  }
});

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Long scard(byte[] key) {
 String command = "scard";
 return instrumented(command, () -> delegated.scard(key));
}

代码示例来源:origin: RedisLabs/redis-quartz

@Override
public int getNumberOfTriggers() throws JobPersistenceException {
 try (Jedis jedis = pool.getResource()) {
   lockPool.acquire();
    return jedis.scard(TRIGGERS_SET).intValue();
  } catch (Exception ex) {
    log.error("could not get number of triggers", ex);
    throw new JobPersistenceException(ex.getMessage(), ex.getCause());
  } finally {
   lockPool.release();
  }
}

代码示例来源:origin: RedisLabs/redis-quartz

@Override
public int getNumberOfJobs() throws JobPersistenceException {
 try (Jedis jedis = pool.getResource()) {
   lockPool.acquire();
    return jedis.scard(JOBS_SET).intValue();
  } catch (Exception ex) {
    log.error("could not get number of jobs", ex);
    throw new JobPersistenceException(ex.getMessage(), ex.getCause());
  } finally {
   lockPool.release();
  }
}

代码示例来源:origin: seawaylee/doubanWebSpider

public int getTotalRequestsCount(Task task) {
  Jedis jedis = getJedis();
  try {
    Long size = jedis.scard(getQueueKey(task));
    return size.intValue();
  } finally {
    pool.returnResource(jedis);
  }
}

代码示例来源:origin: yangfuhai/jboot

/**
 * 返回集合 key 的基数(集合中元素的数量)。
 */
public Long scard(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.scard(keyToBytes(key));
  } finally {
    returnResource(jedis);
  }
}

代码示例来源:origin: com.github.sogyf/goja-jfinal

/**
 * 返回集合 key 的基数(集合中元素的数量)。
 */
public Long scard(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.scard(keyToBytes(key));
  }
  finally {close(jedis);}
}

相关文章

Jedis类方法