Skip to content

Commit 06d1fe5

Browse files
Merge branch 'main' into DOC-4756-sorted-set-async-examples
2 parents 83842be + 0776653 commit 06d1fe5

File tree

45 files changed

+130
-1847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+130
-1847
lines changed

docs/advanced-usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ events is:
11331133
`ConnectionDeactivatedEvent`
11341134

11351135
5. Since 5.3: Reconnect failed: A reconnect attempt failed. Contains
1136-
the reconnect failure and and the retry counter. Event type:
1136+
the reconnect failure and the retry counter. Event type:
11371137
`ReconnectFailedEvent`
11381138

11391139
#### Metrics events
@@ -2515,7 +2515,7 @@ Commands that are issued as long as the failure persists are buffered.
25152515

25162516
#### Exceptions to *at-least-once*
25172517

2518-
Lettuce does not loose commands while sending them. A command execution
2518+
Lettuce does not lose commands while sending them. A command execution
25192519
can, however, fail for the same reasons as a normal method call can on
25202520
the JVM:
25212521

@@ -2558,7 +2558,7 @@ from the response queue, and the connection stays usable.
25582558

25592559
In general, when `Errors` occur while operating on a connection, you
25602560
should close the connection and use a new one. Connections, that
2561-
experienced such severe failures get into a unrecoverable state, and no
2561+
experienced such severe failures get into an unrecoverable state, and no
25622562
further response processing is possible.
25632563

25642564
Executing commands more than once

src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@
4848
import io.lettuce.core.protocol.CommandType;
4949
import io.lettuce.core.protocol.ProtocolKeyword;
5050
import io.lettuce.core.protocol.RedisCommand;
51-
import io.lettuce.core.search.Field;
52-
import io.lettuce.core.search.arguments.CreateArgs;
53-
import reactor.core.publisher.Mono;
5451

5552
import java.time.Duration;
5653
import java.time.Instant;
5754
import java.util.Date;
5855
import java.util.List;
5956
import java.util.Map;
6057
import java.util.Set;
58+
import java.util.function.Supplier;
6159

6260
import static io.lettuce.core.ClientOptions.DEFAULT_JSON_PARSER;
6361
import static io.lettuce.core.protocol.CommandType.EXEC;
@@ -81,18 +79,15 @@ public abstract class AbstractRedisAsyncCommands<K, V> implements RedisAclAsyncC
8179
RedisKeyAsyncCommands<K, V>, RedisStringAsyncCommands<K, V>, RedisListAsyncCommands<K, V>, RedisSetAsyncCommands<K, V>,
8280
RedisSortedSetAsyncCommands<K, V>, RedisScriptingAsyncCommands<K, V>, RedisServerAsyncCommands<K, V>,
8381
RedisHLLAsyncCommands<K, V>, BaseRedisAsyncCommands<K, V>, RedisTransactionalAsyncCommands<K, V>,
84-
RedisGeoAsyncCommands<K, V>, RedisClusterAsyncCommands<K, V>, RedisJsonAsyncCommands<K, V>,
85-
RediSearchAsyncCommands<K, V> {
82+
RedisGeoAsyncCommands<K, V>, RedisClusterAsyncCommands<K, V>, RedisJsonAsyncCommands<K, V> {
8683

8784
private final StatefulConnection<K, V> connection;
8885

8986
private final RedisCommandBuilder<K, V> commandBuilder;
9087

9188
private final RedisJsonCommandBuilder<K, V> jsonCommandBuilder;
9289

93-
private final RediSearchCommandBuilder<K, V> searchCommandBuilder;
94-
95-
private final Mono<JsonParser> parser;
90+
private final Supplier<JsonParser> parser;
9691

9792
/**
9893
* Initialize a new instance.
@@ -101,12 +96,12 @@ public abstract class AbstractRedisAsyncCommands<K, V> implements RedisAclAsyncC
10196
* @param codec the codec for command encoding
10297
* @param parser the implementation of the {@link JsonParser} to use
10398
*/
104-
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
99+
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec,
100+
Supplier<JsonParser> parser) {
105101
this.parser = parser;
106102
this.connection = connection;
107103
this.commandBuilder = new RedisCommandBuilder<>(codec);
108104
this.jsonCommandBuilder = new RedisJsonCommandBuilder<>(codec, parser);
109-
this.searchCommandBuilder = new RediSearchCommandBuilder<>(codec);
110105
}
111106

112107
/**
@@ -1484,11 +1479,6 @@ public boolean isOpen() {
14841479
return connection.isOpen();
14851480
}
14861481

1487-
@Override
1488-
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
1489-
return dispatch(searchCommandBuilder.ftCreate(index, options, fields));
1490-
}
1491-
14921482
@Override
14931483
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
14941484
return dispatch(jsonCommandBuilder.jsonArrappend(key, jsonPath, values));
@@ -3407,7 +3397,7 @@ public RedisFuture<List<Map<String, Object>>> clusterLinks() {
34073397

34083398
@Override
34093399
public JsonParser getJsonParser() {
3410-
return this.parser.block();
3400+
return this.parser.get();
34113401
}
34123402

34133403
private byte[] encodeFunction(String functionCode) {

src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
import io.lettuce.core.protocol.RedisCommand;
5050
import io.lettuce.core.protocol.TracedCommand;
5151
import io.lettuce.core.resource.ClientResources;
52-
import io.lettuce.core.search.Field;
53-
import io.lettuce.core.search.arguments.CreateArgs;
5452
import io.lettuce.core.tracing.TraceContext;
5553
import io.lettuce.core.tracing.TraceContextProvider;
5654
import io.lettuce.core.tracing.Tracing;
@@ -86,22 +84,20 @@
8684
* @author Tihomir Mateev
8785
* @since 4.0
8886
*/
89-
public abstract class AbstractRedisReactiveCommands<K, V> implements RedisAclReactiveCommands<K, V>,
90-
RedisHashReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>, RedisStringReactiveCommands<K, V>,
91-
RedisListReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>, RedisSortedSetReactiveCommands<K, V>,
92-
RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>, RedisHLLReactiveCommands<K, V>,
93-
BaseRedisReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>,
94-
RedisClusterReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>, RediSearchReactiveCommands<K, V> {
87+
public abstract class AbstractRedisReactiveCommands<K, V>
88+
implements RedisAclReactiveCommands<K, V>, RedisHashReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>,
89+
RedisStringReactiveCommands<K, V>, RedisListReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>,
90+
RedisSortedSetReactiveCommands<K, V>, RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>,
91+
RedisHLLReactiveCommands<K, V>, BaseRedisReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>,
92+
RedisGeoReactiveCommands<K, V>, RedisClusterReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V> {
9593

9694
private final StatefulConnection<K, V> connection;
9795

9896
private final RedisCommandBuilder<K, V> commandBuilder;
9997

10098
private final RedisJsonCommandBuilder<K, V> jsonCommandBuilder;
10199

102-
private final RediSearchCommandBuilder<K, V> searchCommandBuilder;
103-
104-
private final Mono<JsonParser> parser;
100+
private final Supplier<JsonParser> parser;
105101

106102
private final ClientResources clientResources;
107103

@@ -116,12 +112,12 @@ public abstract class AbstractRedisReactiveCommands<K, V> implements RedisAclRea
116112
* @param codec the codec for command encoding.
117113
* @param parser the implementation of the {@link JsonParser} to use
118114
*/
119-
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
115+
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec,
116+
Supplier<JsonParser> parser) {
120117
this.connection = connection;
121118
this.parser = parser;
122119
this.commandBuilder = new RedisCommandBuilder<>(codec);
123120
this.jsonCommandBuilder = new RedisJsonCommandBuilder<>(codec, parser);
124-
this.searchCommandBuilder = new RediSearchCommandBuilder<>(codec);
125121
this.clientResources = connection.getResources();
126122
this.tracingEnabled = clientResources.tracing().isEnabled();
127123
}
@@ -154,7 +150,7 @@ private EventExecutorGroup getScheduler() {
154150

155151
@Override
156152
public JsonParser getJsonParser() {
157-
return parser.block();
153+
return parser.get();
158154
}
159155

160156
@Override
@@ -1548,11 +1544,6 @@ public boolean isOpen() {
15481544
return connection.isOpen();
15491545
}
15501546

1551-
@Override
1552-
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
1553-
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fields));
1554-
}
1555-
15561547
@Override
15571548
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
15581549
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

src/main/java/io/lettuce/core/ClientOptions.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Iterator;
2626
import java.util.ServiceConfigurationError;
2727
import java.util.ServiceLoader;
28+
import java.util.function.Supplier;
2829

2930
import io.lettuce.core.api.StatefulConnection;
3031
import io.lettuce.core.internal.LettuceAssert;
@@ -71,15 +72,15 @@ public class ClientOptions implements Serializable {
7172

7273
public static final SocketOptions DEFAULT_SOCKET_OPTIONS = SocketOptions.create();
7374

74-
public static final Mono<JsonParser> DEFAULT_JSON_PARSER = Mono.defer(() -> Mono.fromCallable(() -> {
75+
public static final Supplier<JsonParser> DEFAULT_JSON_PARSER = () -> {
7576
try {
7677
Iterator<JsonParser> services = ServiceLoader.load(JsonParser.class).iterator();
7778
return services.hasNext() ? services.next() : null;
7879
} catch (ServiceConfigurationError e) {
7980
throw new RedisJsonException("Could not load JsonParser, please consult the guide"
8081
+ "at https://redis.github.io/lettuce/user-guide/redis-json/", e);
8182
}
82-
}));
83+
};
8384

8485
public static final SslOptions DEFAULT_SSL_OPTIONS = SslOptions.create();
8586

@@ -111,7 +112,7 @@ public class ClientOptions implements Serializable {
111112

112113
private final Charset scriptCharset;
113114

114-
private final Mono<JsonParser> jsonParser;
115+
private final Supplier<JsonParser> jsonParser;
115116

116117
private final SocketOptions socketOptions;
117118

@@ -216,7 +217,7 @@ public static class Builder {
216217

217218
private Charset scriptCharset = DEFAULT_SCRIPT_CHARSET;
218219

219-
private Mono<JsonParser> jsonParser = DEFAULT_JSON_PARSER;
220+
private Supplier<JsonParser> jsonParser = DEFAULT_JSON_PARSER;
220221

221222
private SocketOptions socketOptions = DEFAULT_SOCKET_OPTIONS;
222223

@@ -429,7 +430,7 @@ public Builder scriptCharset(Charset scriptCharset) {
429430
* @see JsonParser
430431
* @since 6.5
431432
*/
432-
public Builder jsonParser(Mono<JsonParser> parser) {
433+
public Builder jsonParser(Supplier<JsonParser> parser) {
433434

434435
LettuceAssert.notNull(parser, "JsonParser must not be null");
435436
this.jsonParser = parser;
@@ -705,7 +706,7 @@ public Charset getScriptCharset() {
705706
* @return the implementation of the {@link JsonParser} to use.
706707
* @since 6.5
707708
*/
708-
public Mono<JsonParser> getJsonParser() {
709+
public Supplier<JsonParser> getJsonParser() {
709710
return jsonParser;
710711
}
711712

src/main/java/io/lettuce/core/RediSearchCommandBuilder.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands;
66
import io.lettuce.core.codec.RedisCodec;
77
import io.lettuce.core.json.JsonParser;
8-
import reactor.core.publisher.Mono;
8+
import java.util.function.Supplier;
99

1010
/**
1111
* An asynchronous and thread-safe API for a Redis connection.
@@ -24,7 +24,8 @@ public class RedisAsyncCommandsImpl<K, V> extends AbstractRedisAsyncCommands<K,
2424
* @param codec the codec for command encoding
2525
* @param parser the implementation of the {@link JsonParser} to use
2626
*/
27-
public RedisAsyncCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
27+
public RedisAsyncCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec,
28+
Supplier<JsonParser> parser) {
2829
super(connection, codec, parser);
2930
}
3031

src/main/java/io/lettuce/core/RedisJsonCommandBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import io.lettuce.core.protocol.BaseRedisCommandBuilder;
2121
import io.lettuce.core.protocol.Command;
2222
import io.lettuce.core.protocol.CommandArgs;
23-
import reactor.core.publisher.Mono;
2423

2524
import java.util.List;
25+
import java.util.function.Supplier;
2626

2727
import static io.lettuce.core.protocol.CommandType.*;
2828

@@ -34,9 +34,9 @@
3434
*/
3535
class RedisJsonCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
3636

37-
private final Mono<JsonParser> parser;
37+
private final Supplier<JsonParser> parser;
3838

39-
RedisJsonCommandBuilder(RedisCodec<K, V> codec, Mono<JsonParser> theParser) {
39+
RedisJsonCommandBuilder(RedisCodec<K, V> codec, Supplier<JsonParser> theParser) {
4040
super(codec);
4141
parser = theParser;
4242
}
@@ -118,7 +118,7 @@ Command<K, V, List<JsonValue>> jsonArrpop(K key, JsonPath jsonPath, int index) {
118118
}
119119
}
120120

121-
return createCommand(JSON_ARRPOP, new JsonValueListOutput<>(codec, parser.block()), args);
121+
return createCommand(JSON_ARRPOP, new JsonValueListOutput<>(codec, parser.get()), args);
122122
}
123123

124124
Command<K, V, List<Long>> jsonArrtrim(K key, JsonPath jsonPath, JsonRangeArgs range) {
@@ -167,7 +167,7 @@ Command<K, V, List<JsonValue>> jsonGet(K key, JsonGetArgs options, JsonPath... j
167167
}
168168
}
169169

170-
return createCommand(JSON_GET, new JsonValueListOutput<>(codec, parser.block()), args);
170+
return createCommand(JSON_GET, new JsonValueListOutput<>(codec, parser.get()), args);
171171
}
172172

173173
Command<K, V, String> jsonMerge(K key, JsonPath jsonPath, JsonValue value) {
@@ -194,7 +194,7 @@ Command<K, V, List<JsonValue>> jsonMGet(JsonPath jsonPath, K... keys) {
194194
args.add(jsonPath.toString());
195195
}
196196

197-
return createCommand(JSON_MGET, new JsonValueListOutput<>(codec, parser.block()), args);
197+
return createCommand(JSON_MGET, new JsonValueListOutput<>(codec, parser.get()), args);
198198
}
199199

200200
Command<K, V, String> jsonMSet(List<JsonMsetArgs<K, V>> arguments) {

src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import io.lettuce.core.json.JsonParser;
88
import reactor.core.publisher.Mono;
99

10+
import java.util.function.Supplier;
11+
1012
/**
1113
* A reactive and thread-safe API for a Redis Sentinel connection.
1214
*
@@ -25,7 +27,7 @@ public class RedisReactiveCommandsImpl<K, V> extends AbstractRedisReactiveComman
2527
* @param parser the implementation of the {@link JsonParser} to use
2628
*/
2729
public RedisReactiveCommandsImpl(StatefulRedisConnection<K, V> connection, RedisCodec<K, V> codec,
28-
Mono<JsonParser> parser) {
30+
Supplier<JsonParser> parser) {
2931
super(connection, codec, parser);
3032
}
3133

0 commit comments

Comments
 (0)