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

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

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

Jedis.llen介绍

[英]Return the length of the list stored at the specified key. If the key does not exist zero is returned (the same behaviour as for empty lists). If the value stored at key is not a list an error is returned.

Time complexity: O(1)
[中]返回存储在指定键处的列表长度。如果密钥不存在,则返回零(与空列表的行为相同)。如果键处存储的值不是列表,则返回错误。
时间复杂度:O(1)

代码示例

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

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

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

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

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

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

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

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

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

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

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

@Override
public Long llen(String key) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.llen(key);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

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

/**
 * 获取会话列表
 * @param offset
 * @param limit
 * @return
 */
public Map getActiveSessions(int offset, int limit) {
  Map sessions = new HashMap();
  Jedis jedis = RedisUtil.getJedis();
  // 获取在线会话总数
  long total = jedis.llen(ZHENG_UPMS_SERVER_SESSION_IDS);
  // 获取当前页会话详情
  List<String> ids = jedis.lrange(ZHENG_UPMS_SERVER_SESSION_IDS, offset, (offset + limit - 1));
  List<Session> rows = new ArrayList<>();
  for (String id : ids) {
    String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + id);
    // 过滤redis过期session
    if (null == session) {
      RedisUtil.lrem(ZHENG_UPMS_SERVER_SESSION_IDS, 1, id);
      total = total - 1;
      continue;
    }
     rows.add(SerializableUtil.deserialize(session));
  }
  jedis.close();
  sessions.put("total", total);
  sessions.put("rows", rows);
  return sessions;
}

代码示例来源: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 的长度。
 * 如果 key 不存在,则 key 被解释为一个空列表,返回 0 .
 * 如果 key 不是列表类型,返回一个错误。
 */
public Long llen(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.llen(keyToBytes(key));
  }
  finally {close(jedis);}
}

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

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

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

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

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    return jedis.llen(key);
  }
});

代码示例来源:origin: iipc/openwayback

public void run(Jedis jedis)
  {
    if (jedis.llen(list) < maxSize) {
      jedis.rpush(list, key);
    }
  }
});

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

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

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

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

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public Long llen(String key) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.llen(key);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

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

/**
 * 返回列表 key 的长度。
 * 如果 key 不存在,则 key 被解释为一个空列表,返回 0 .
 * 如果 key 不是列表类型,返回一个错误。
 */
public Long llen(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.llen(keyToBytes(key));
  } finally {
    returnResource(jedis);
  }
}

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

/**
 * 返回列表 key 的长度。
 * 如果 key 不存在,则 key 被解释为一个空列表,返回 0 .
 * 如果 key 不是列表类型,返回一个错误。
 */
public Long llen(Object key) {
  Jedis jedis = getJedis();
  try {
    return jedis.llen(keyToBytes(key));
  }
  finally {close(jedis);}
}

代码示例来源:origin: xetorthio/johm

public Long llen() {
  Jedis jedis = getResource();
  Long llen = jedis.llen(key());
  returnResource(jedis);
  return llen;
}

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

protected KeyInfo handleList(final Jedis jedis) {
  final KeyInfo keyInfo = new KeyInfo(this.key, KeyType.LIST);
  keyInfo.setSize(jedis.llen(this.key));
  if (this.doArrayValue) {
    keyInfo.setArrayValue(jedis.lrange(this.key, this.offset, this.offset + this.count));
  }
  return keyInfo;
}

相关文章

Jedis类方法