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

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

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

JedisCluster.blpop介绍

暂无

代码示例

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

@Override
public List<byte[]> bLPop(int timeout, byte[]... keys) {
  Assert.notNull(keys, "Key must not be null!");
  Assert.noNullElements(keys, "Keys must not contain null elements!");
  if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
    try {
      return connection.getCluster().blpop(timeout, keys);
    } catch (Exception ex) {
      throw convertJedisAccessException(ex);
    }
  }
  return connection.getClusterCommandExecutor()
      .executeMultiKeyCommand(
          (JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> client.blpop(timeout, key),
          Arrays.asList(keys))
      .getFirstNonNullNotEmptyOrDefault(Collections.<byte[]> emptyList());
}

代码示例来源:origin: net.oschina.j2cache/j2cache-core

@Override
public List<byte[]> blpop(byte[] bytes) {
  return cluster.blpop(0, bytes);
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public List<String> blpop(int timeout, String... keys) {
  return jedisCluster.blpop(timeout, keys);
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public List<String> blpop(int timeout, String key) {
  return jedisCluster.blpop(timeout, key);
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public List<byte[]> blpop(int timeout, byte[]... keys) {
  return jedisCluster.blpop(timeout, keys);
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

@Deprecated @Override
public List<String> blpop(String arg) {
  return jedisCluster.blpop(arg);
}
@Deprecated @Override

代码示例来源:origin: hhfcyong/xxxx-dubbo

/**
 *  LPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BLPOP 命令阻塞,直到等待超时或发现可弹出元素为止
 * @param timeout 超时时间,设置为0 表示无限制等待
 * @param key
 * @return
 */
public String blpop(int timeout,String key){
  List<String> value=jedisCluster.blpop(timeout, key);
  return value.get(0);
}
/**

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

/**
   * BLPOP 是列表的阻塞式(blocking)弹出原语。
   * 它是 LPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BLPOP 命令阻塞,直到等待超时或发现可弹出元素为止。
   * 当给定多个 key 参数时,按参数 key 的先后顺序依次检查各个列表,弹出第一个非空列表的头元素。
   */
  @SuppressWarnings("rawtypes")
  public List blpop(Object... keys) {
//        String[] keysStrings = new String[keys.length];
//        for (int i = 0; i < keys.length; i++) {
//            keysStrings[i] = keys[i].toString();
//        }
    
    List<byte[]> data = jedisCluster.blpop(timeout, keysToBytesArray(keys));

    if (data != null && data.size() == 2) {
      List<Object> objects = new ArrayList<>();
      objects.add(new String(data.get(0)));
      objects.add(valueFromBytes(data.get(1)));
      return objects;
    }

    return valueListFromBytesList(data);

  }

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

/**
 * BLPOP 是列表的阻塞式(blocking)弹出原语。
 * 它是 LPOP 命令的阻塞版本,当给定列表内没有任何元素可供弹出的时候,连接将被 BLPOP 命令阻塞,直到等待超时或发现可弹出元素为止。
 * 当给定多个 key 参数时,按参数 key 的先后顺序依次检查各个列表,弹出第一个非空列表的头元素。
 */
@SuppressWarnings("rawtypes")
public List blpop(Integer timeout, Object... keys) {
  List<byte[]> data = jedisCluster.blpop(timeout, keysToBytesArray(keys));
  return valueListFromBytesList(data);
}

代码示例来源:origin: com.github.yamingd.argo/argo-redis

@Override
public List<String> blpop(int timeout, String... keys) {
  List<byte[]> bs = jedisCluster.blpop(timeout, SafeEncoder.encodeMany(keys));
  return fromBytes(bs);
}

代码示例来源:origin: com.github.yamingd.argo/argo-redis

@Override
public <T> List<T> blpop(Class<T> clazz, int timeout, String... keys) {
  List<byte[]> bs = jedisCluster.blpop(timeout, SafeEncoder.encodeMany(keys));
  return fromBytes(clazz, bs);
}

代码示例来源:origin: org.nanoframework/nano-orm-jedis

switch (pop) {
  case LPOP:
    values = cluster.blpop(timeout, keys);
    break;
  case RPOP:

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

@Override
public List<byte[]> bLPop(int timeout, byte[]... keys) {
  Assert.notNull(keys, "Key must not be null!");
  Assert.noNullElements(keys, "Keys must not contain null elements!");
  if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
    try {
      return connection.getCluster().blpop(timeout, keys);
    } catch (Exception ex) {
      throw convertJedisAccessException(ex);
    }
  }
  return connection.getClusterCommandExecutor()
      .executeMultiKeyCommand(
          (JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> client.blpop(timeout, key),
          Arrays.asList(keys))
      .getFirstNonNullNotEmptyOrDefault(Collections.<byte[]> emptyList());
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public List<byte[]> bLPop(int timeout, byte[]... keys) {
  Assert.notNull(keys, "Key must not be null!");
  Assert.noNullElements(keys, "Keys must not contain null elements!");
  if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
    try {
      return connection.getCluster().blpop(timeout, keys);
    } catch (Exception ex) {
      throw convertJedisAccessException(ex);
    }
  }
  return connection.getClusterCommandExecutor()
      .executeMultiKeyCommand(
          (JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> client.blpop(timeout, key),
          Arrays.asList(keys))
      .getFirstNonNullNotEmptyOrDefault(Collections.<byte[]> emptyList());
}

代码示例来源:origin: org.nanoframework/nano-orm-jedis

@Override
public String bpop(final String key, final int timeout, final Mark pop) {
  Assert.hasText(key);
  Assert.notNull(pop);
  try {
    final List<String> values;
    switch (pop) {
      case LPOP:
        values = cluster.blpop(timeout, key);
        break;
      case RPOP:
        values = cluster.brpop(timeout, key);
        break;
      default:
        throw new RedisClientException("Unknown Pop type");
    }
    if (!CollectionUtils.isEmpty(values)) {
      return values.get(1);
    }
    return null;
  } catch (final Throwable e) {
    throw new RedisClientException(e.getMessage(), e);
  }
}

相关文章

微信公众号

最新文章

更多

JedisCluster类方法