io.lettuce.core.KeyValue.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(160)

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

KeyValue.getValue介绍

暂无

代码示例

代码示例来源:origin: lettuce-io/lettuce-core

@Override
public int hashCode() {
  int result = key.hashCode();
  result = 31 * result + (hasValue() ? getValue().hashCode() : 0);
  return result;
}

代码示例来源:origin: lettuce-io/lettuce-core

@Override
public String toString() {
  return hasValue() ? String.format("KeyValue[%s, %s]", key, getValue()) : String.format("KeyValue[%s].empty", key);
}

代码示例来源:origin: lettuce-io/lettuce-core

/**
   * Returns a {@link KeyValue} consisting of the results of applying the given function to the value of this element. Mapping
   * is performed only if a {@link #hasValue() value is present}.
   *
   * @param <R> The element type of the new {@link KeyValue}
   * @param mapper a stateless function to apply to each element
   * @return the new {@link KeyValue}
   */
  @SuppressWarnings("unchecked")
  public <R> KeyValue<K, R> map(Function<? super V, ? extends R> mapper) {

    LettuceAssert.notNull(mapper, "Mapper function must not be null");

    if (hasValue()) {
      return new KeyValue<>(getKey(), mapper.apply(getValue()));
    }

    return (KeyValue<K, R>) this;
  }
}

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

@Override
public Flux<PopResponse> bPop(Publisher<BPopCommand> commands) {
  return connection.executeDedicated(cmd -> Flux.from(commands).concatMap(command -> {
    Assert.notNull(command.getKeys(), "Keys must not be null!");
    Assert.notNull(command.getDirection(), "Direction must not be null!");
    long timeout = command.getTimeout().get(ChronoUnit.SECONDS);
    Mono<PopResult> mappedMono = (ObjectUtils.nullSafeEquals(Direction.RIGHT, command.getDirection())
        ? cmd.brpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new))
        : cmd.blpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new)))
            .map(kv -> Arrays.asList(kv.getKey(), kv.getValue())).map(PopResult::new);
    return mappedMono.map(value -> new PopResponse(command, value));
  }));
}

代码示例来源:origin: alibaba/jetcache

K key = keyList.get(i);
if (kv != null && kv.hasValue()) {
  CacheValueHolder<V> holder = (CacheValueHolder<V>) valueDecoder.apply((byte[]) kv.getValue());
  if (System.currentTimeMillis() >= holder.getExpireTime()) {
    resultMap.put(key, CacheGetResult.EXPIRED_WITHOUT_MSG);

代码示例来源:origin: io.lettuce/lettuce-core

@Override
public int hashCode() {
  int result = key.hashCode();
  result = 31 * result + (hasValue() ? getValue().hashCode() : 0);
  return result;
}

代码示例来源:origin: io.lettuce/lettuce-core

@Override
public String toString() {
  return hasValue() ? String.format("KeyValue[%s, %s]", key, getValue()) : String.format("KeyValue[%s].empty", key);
}

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

@Override
public List<byte[]> getBytes(Collection<String> keys) {
  try(StatefulConnection<String, byte[]> connection = super.connect()) {
    RedisHashCommands<String, byte[]> cmd = (RedisHashCommands)super.sync(connection);
    return cmd.hmget(this.region, keys.stream().toArray(String[]::new)).stream().map(kv -> kv.hasValue()?kv.getValue():null).collect(Collectors.toList());
  }
}

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

@Override
public List<byte[]> getBytes(Collection<String> keys) {
  try(StatefulConnection<String, byte[]> connection = super.connect()) {
    RedisStringCommands<String, byte[]> cmd = (RedisStringCommands)super.sync(connection);
    return cmd.mget(keys.stream().map(k -> _key(k)).toArray(String[]::new)).stream().map(kv -> kv.hasValue()?kv.getValue():null).collect(Collectors.toList());
  }
}

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

@Override
public Flux<PopResponse> bPop(Publisher<BPopCommand> commands) {
  return connection.executeDedicated(cmd -> Flux.from(commands).concatMap(command -> {
    Assert.notNull(command.getKeys(), "Keys must not be null!");
    Assert.notNull(command.getDirection(), "Direction must not be null!");
    long timeout = command.getTimeout().get(ChronoUnit.SECONDS);
    Mono<PopResult> mappedMono = (ObjectUtils.nullSafeEquals(Direction.RIGHT, command.getDirection())
        ? cmd.brpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new))
        : cmd.blpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new)))
            .map(kv -> Arrays.asList(kv.getKey(), kv.getValue())).map(PopResult::new);
    return mappedMono.map(value -> new PopResponse(command, value));
  }));
}

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

@Override
public Flux<PopResponse> bPop(Publisher<BPopCommand> commands) {
  return connection.executeDedicated(cmd -> Flux.from(commands).concatMap(command -> {
    Assert.notNull(command.getKeys(), "Keys must not be null!");
    Assert.notNull(command.getDirection(), "Direction must not be null!");
    long timeout = command.getTimeout().get(ChronoUnit.SECONDS);
    Mono<PopResult> mappedMono = (ObjectUtils.nullSafeEquals(Direction.RIGHT, command.getDirection())
        ? cmd.brpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new))
        : cmd.blpop(timeout, command.getKeys().stream().toArray(ByteBuffer[]::new)))
            .map(kv -> Arrays.asList(kv.getKey(), kv.getValue())).map(PopResult::new);
    return mappedMono.map(value -> new PopResponse(command, value));
  }));
}

代码示例来源:origin: io.lettuce/lettuce-core

/**
   * Returns a {@link KeyValue} consisting of the results of applying the given function to the value of this element. Mapping
   * is performed only if a {@link #hasValue() value is present}.
   *
   * @param <R> The element type of the new {@link KeyValue}
   * @param mapper a stateless function to apply to each element
   * @return the new {@link KeyValue}
   */
  @SuppressWarnings("unchecked")
  public <R> KeyValue<K, R> map(Function<? super V, ? extends R> mapper) {

    LettuceAssert.notNull(mapper, "Mapper function must not be null");

    if (hasValue()) {
      return new KeyValue<>(getKey(), mapper.apply(getValue()));
    }

    return (KeyValue<K, R>) this;
  }
}

相关文章

微信公众号

最新文章

更多