本文整理了Java中io.lettuce.core.KeyValue.fromNullable()
方法的一些代码示例,展示了KeyValue.fromNullable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.fromNullable()
方法的具体详情如下:
包路径:io.lettuce.core.KeyValue
类名称:KeyValue
方法名:fromNullable
[英]Creates a KeyValue from a key and value. The resulting value contains the value if the value is not null.
[中]从键和值创建键值。如果值不为null,则结果值包含该值。
代码示例来源:origin: lettuce-io/lettuce-core
@Override
protected ScanCursor nextScanCursor(ScanCursor scanCursor) {
MapScanCursor<K, V> cursor = getNextScanCursor(scanCursor);
chunk = cursor.getMap().keySet().stream().map(k -> KeyValue.fromNullable(k, cursor.getMap().get(k))).iterator();
return cursor;
}
代码示例来源:origin: lettuce-io/lettuce-core
@Override
public void set(ByteBuffer bytes) {
if (keyIterator == null) {
keyIterator = keys.iterator();
}
subscriber.onNext(output, KeyValue.fromNullable(keyIterator.next(), bytes == null ? null : codec.decodeValue(bytes)));
}
代码示例来源:origin: lettuce-io/lettuce-core
@Override
public void set(ByteBuffer bytes) {
if (bytes != null) {
if (key == null) {
key = codec.decodeKey(bytes);
} else {
V value = codec.decodeValue(bytes);
output = KeyValue.fromNullable(key, value);
}
}
}
}
代码示例来源:origin: lettuce-io/lettuce-core
private static <K, V> Flux<KeyValue<K, V>> hscan(RedisHashReactiveCommands<K, V> commands, K key,
Optional<ScanArgs> scanArgs) {
LettuceAssert.notNull(commands, "RedisHashReactiveCommands must not be null");
LettuceAssert.notNull(key, "Key must not be null");
return Flux.create(sink -> {
Mono<MapScanCursor<K, V>> res = scanArgs.map(it -> commands.hscan(key, it)).orElseGet(() -> commands.hscan(key));
scan(sink, res, c -> scanArgs.map(it -> commands.hscan(key, c, it)).orElseGet(() -> commands.hscan(key, c)), //
c -> {
List<KeyValue<K, V>> list = new ArrayList<>(c.getMap().size());
for (Map.Entry<K, V> kvEntry : c.getMap().entrySet()) {
list.add(KeyValue.fromNullable(kvEntry.getKey(), kvEntry.getValue()));
}
return list;
});
});
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
代码示例来源:origin: io.lettuce/lettuce-core
@Override
public void set(ByteBuffer bytes) {
if (keyIterator == null) {
keyIterator = keys.iterator();
}
subscriber.onNext(output, KeyValue.fromNullable(keyIterator.next(), bytes == null ? null : codec.decodeValue(bytes)));
}
代码示例来源:origin: io.lettuce/lettuce-core
@Override
protected ScanCursor nextScanCursor(ScanCursor scanCursor) {
MapScanCursor<K, V> cursor = getNextScanCursor(scanCursor);
chunk = cursor.getMap().keySet().stream().map(k -> KeyValue.fromNullable(k, cursor.getMap().get(k))).iterator();
return cursor;
}
代码示例来源:origin: io.lettuce/lettuce-core
@Override
public void set(ByteBuffer bytes) {
if (bytes != null) {
if (key == null) {
key = codec.decodeKey(bytes);
} else {
V value = codec.decodeValue(bytes);
output = KeyValue.fromNullable(key, value);
}
}
}
}
代码示例来源:origin: io.lettuce/lettuce-core
private static <K, V> Flux<KeyValue<K, V>> hscan(RedisHashReactiveCommands<K, V> commands, K key,
Optional<ScanArgs> scanArgs) {
LettuceAssert.notNull(commands, "RedisHashReactiveCommands must not be null");
LettuceAssert.notNull(key, "Key must not be null");
return Flux.create(sink -> {
Mono<MapScanCursor<K, V>> res = scanArgs.map(it -> commands.hscan(key, it)).orElseGet(() -> commands.hscan(key));
scan(sink, res, c -> scanArgs.map(it -> commands.hscan(key, c, it)).orElseGet(() -> commands.hscan(key, c)), //
c -> {
List<KeyValue<K, V>> list = new ArrayList<>(c.getMap().size());
for (Map.Entry<K, V> kvEntry : c.getMap().entrySet()) {
list.add(KeyValue.fromNullable(kvEntry.getKey(), kvEntry.getValue()));
}
return list;
});
});
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
内容来源于网络,如有侵权,请联系作者删除!