Skip to content

Commit b26a932

Browse files
committed
DATAREDIS-1223 - Upgrade to Lettuce 6.0 GA.
Adopt HashCommands to changed HGETALL method signature returning Flux<KeyValue> instead of Mono<Map>.
1 parent f1d8848 commit b26a932

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<beanutils>1.9.2</beanutils>
2323
<xstream>1.4.12</xstream>
2424
<pool>2.7.0</pool>
25-
<lettuce>6.0.0.RC2</lettuce>
25+
<lettuce>6.0.0.RELEASE</lettuce>
2626
<jedis>3.3.0</jedis>
2727
<multithreadedtc>1.01</multithreadedtc>
2828
<netty>4.1.51.Final</netty>

src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommands.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.stream.Collectors;
2929

3030
import org.reactivestreams.Publisher;
31+
3132
import org.springframework.data.redis.connection.ReactiveHashCommands;
3233
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
3334
import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse;
@@ -209,9 +210,9 @@ public Flux<CommandResponse<KeyCommand, Flux<Map.Entry<ByteBuffer, ByteBuffer>>>
209210

210211
Assert.notNull(command.getKey(), "Key must not be null!");
211212

212-
Mono<Map<ByteBuffer, ByteBuffer>> result = cmd.hgetall(command.getKey());
213+
Flux<KeyValue<ByteBuffer, ByteBuffer>> result = cmd.hgetall(command.getKey());
213214

214-
return Mono.just(new CommandResponse<>(command, result.flatMapMany(v -> Flux.fromStream(v.entrySet().stream()))));
215+
return Mono.just(new CommandResponse<>(command, result.map(LettuceReactiveHashCommands::toEntry)));
215216
}));
216217
}
217218

@@ -268,4 +269,25 @@ public Flux<NumericResponse<HStrLenCommand, Long>> hStrLen(Publisher<HStrLenComm
268269
return cmd.hstrlen(command.getKey(), command.getField()).map(value -> new NumericResponse<>(command, value));
269270
}));
270271
}
272+
273+
private static Map.Entry<ByteBuffer, ByteBuffer> toEntry(KeyValue<ByteBuffer, ByteBuffer> kv) {
274+
275+
return new Entry<ByteBuffer, ByteBuffer>() {
276+
277+
@Override
278+
public ByteBuffer getKey() {
279+
return kv.getKey();
280+
}
281+
282+
@Override
283+
public ByteBuffer getValue() {
284+
return kv.getValue();
285+
}
286+
287+
@Override
288+
public ByteBuffer setValue(ByteBuffer value) {
289+
throw new UnsupportedOperationException("Cannot set value for entry");
290+
}
291+
};
292+
}
271293
}

0 commit comments

Comments
 (0)