Skip to content

Commit bb9b5e8

Browse files
committed
The KEYS command needs to be keyless
1 parent 9ecee24 commit bb9b5e8

20 files changed

+159
-40
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,12 +1826,12 @@ public RedisFuture<Map<V, Double>> vsimWithScore(K key, VSimArgs args, V element
18261826
}
18271827

18281828
@Override
1829-
public RedisFuture<List<K>> keys(K pattern) {
1829+
public RedisFuture<List<K>> keys(String pattern) {
18301830
return dispatch(commandBuilder.keys(pattern));
18311831
}
18321832

18331833
@Override
1834-
public RedisFuture<Long> keys(KeyStreamingChannel<K> channel, K pattern) {
1834+
public RedisFuture<Long> keys(KeyStreamingChannel<K> channel, String pattern) {
18351835
return dispatch(commandBuilder.keys(channel, pattern));
18361836
}
18371837

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,12 +1893,12 @@ public Mono<Map<V, Double>> vsimWithScore(K key, VSimArgs args, V element) {
18931893
}
18941894

18951895
@Override
1896-
public Flux<K> keys(K pattern) {
1896+
public Flux<K> keys(String pattern) {
18971897
return createDissolvingFlux(() -> commandBuilder.keys(pattern));
18981898
}
18991899

19001900
@Override
1901-
public Mono<Long> keys(KeyStreamingChannel<K> channel, K pattern) {
1901+
public Mono<Long> keys(KeyStreamingChannel<K> channel, String pattern) {
19021902
return createMono(() -> commandBuilder.keys(channel, pattern));
19031903
}
19041904

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,17 +1900,19 @@ Command<K, V, String> info(String section) {
19001900
return createCommand(CommandType.INFO, new StatusOutput<>(codec), args);
19011901
}
19021902

1903-
Command<K, V, List<K>> keys(K pattern) {
1903+
Command<K, V, List<K>> keys(String pattern) {
19041904
LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL);
19051905

1906-
return createCommand(KEYS, new KeyListOutput<>(codec), pattern);
1906+
CommandArgs<K, V> args = new CommandArgs<>(codec).addGlobalPattern(pattern);
1907+
return createCommand(KEYS, new GlobPatternOutput<>(codec), args);
19071908
}
19081909

1909-
Command<K, V, Long> keys(KeyStreamingChannel<K> channel, K pattern) {
1910+
Command<K, V, Long> keys(KeyStreamingChannel<K> channel, String pattern) {
19101911
LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL);
19111912
notNull(channel);
19121913

1913-
return createCommand(KEYS, new KeyStreamingOutput<>(codec, channel), pattern);
1914+
CommandArgs<K, V> args = new CommandArgs<>(codec).addGlobalPattern(pattern);
1915+
return createCommand(KEYS, new GlobPatternStreamingOutput<>(codec, channel), args);
19141916
}
19151917

19161918
Command<K, V, Date> lastsave() {

src/main/templates/io/lettuce/core/api/RedisKeyCommands.java renamed to src/main/java/io/lettuce/core/api/RedisKeyCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public interface RedisKeyCommands<K, V> {
219219
* @param pattern the pattern type: patternkey (pattern).
220220
* @return List&lt;K&gt; array-reply list of keys matching {@code pattern}.
221221
*/
222-
List<K> keys(K pattern);
222+
List<K> keys(String pattern);
223223

224224
/**
225225
* Find all keys matching the given pattern.
@@ -228,7 +228,7 @@ public interface RedisKeyCommands<K, V> {
228228
* @param pattern the pattern.
229229
* @return Long array-reply list of keys matching {@code pattern}.
230230
*/
231-
Long keys(KeyStreamingChannel<K> channel, K pattern);
231+
Long keys(KeyStreamingChannel<K> channel, String pattern);
232232

233233
/**
234234
* Atomically transfer a key from a Redis instance to another one.

src/main/java/io/lettuce/core/api/async/RedisKeyAsyncCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public interface RedisKeyAsyncCommands<K, V> {
220220
* @param pattern the pattern type: patternkey (pattern).
221221
* @return List&lt;K&gt; array-reply list of keys matching {@code pattern}.
222222
*/
223-
RedisFuture<List<K>> keys(K pattern);
223+
RedisFuture<List<K>> keys(String pattern);
224224

225225
/**
226226
* Find all keys matching the given pattern.
@@ -229,7 +229,7 @@ public interface RedisKeyAsyncCommands<K, V> {
229229
* @param pattern the pattern.
230230
* @return Long array-reply list of keys matching {@code pattern}.
231231
*/
232-
RedisFuture<Long> keys(KeyStreamingChannel<K> channel, K pattern);
232+
RedisFuture<Long> keys(KeyStreamingChannel<K> channel, String pattern);
233233

234234
/**
235235
* Atomically transfer a key from a Redis instance to another one.

src/main/java/io/lettuce/core/api/reactive/RedisKeyReactiveCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public interface RedisKeyReactiveCommands<K, V> {
230230
* @param pattern the pattern type: patternkey (pattern).
231231
* @return K array-reply list of keys matching {@code pattern}.
232232
*/
233-
Flux<K> keys(K pattern);
233+
Flux<K> keys(String pattern);
234234

235235
/**
236236
* Find all keys matching the given pattern.
@@ -242,7 +242,7 @@ public interface RedisKeyReactiveCommands<K, V> {
242242
* {@link #keys}.
243243
*/
244244
@Deprecated
245-
Mono<Long> keys(KeyStreamingChannel<K> channel, K pattern);
245+
Mono<Long> keys(KeyStreamingChannel<K> channel, String pattern);
246246

247247
/**
248248
* Atomically transfer a key from a Redis instance to another one.

src/main/java/io/lettuce/core/api/sync/RedisKeyCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public interface RedisKeyCommands<K, V> {
229229
* @param pattern the pattern type: patternkey (pattern).
230230
* @return List&lt;K&gt; array-reply list of keys matching {@code pattern}.
231231
*/
232-
List<K> keys(K pattern);
232+
List<K> keys(String pattern);
233233

234234
/**
235235
* Find all keys matching the given pattern.
@@ -238,7 +238,7 @@ public interface RedisKeyCommands<K, V> {
238238
* @param pattern the pattern.
239239
* @return Long array-reply list of keys matching {@code pattern}.
240240
*/
241-
Long keys(KeyStreamingChannel<K> channel, K pattern);
241+
Long keys(KeyStreamingChannel<K> channel, String pattern);
242242

243243
/**
244244
* Atomically transfer a key from a Redis instance to another one.

src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterAsyncCommandsImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public RedisFuture<String> flushdb(FlushMode flushMode) {
276276
}
277277

278278
@Override
279-
public RedisFuture<List<K>> keys(K pattern) {
279+
public RedisFuture<List<K>> keys(String pattern) {
280280

281281
Map<String, CompletableFuture<List<K>>> executions = executeOnUpstream(commands -> commands.keys(pattern));
282282

@@ -290,7 +290,7 @@ public RedisFuture<List<K>> keys(K pattern) {
290290
}
291291

292292
@Override
293-
public RedisFuture<Long> keys(KeyStreamingChannel<K> channel, K pattern) {
293+
public RedisFuture<Long> keys(KeyStreamingChannel<K> channel, String pattern) {
294294

295295
Map<String, CompletableFuture<Long>> executions = executeOnUpstream(commands -> commands.keys(channel, pattern));
296296
return MultiNodeExecution.aggregateAsync(executions);

src/main/java/io/lettuce/core/cluster/RedisAdvancedClusterReactiveCommandsImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ public Mono<String> flushdb(FlushMode flushMode) {
265265
}
266266

267267
@Override
268-
public Flux<K> keys(K pattern) {
268+
public Flux<K> keys(String pattern) {
269269

270270
Map<String, Publisher<K>> publishers = executeOnUpstream(commands -> commands.keys(pattern));
271271
return Flux.merge(publishers.values());
272272
}
273273

274274
@Override
275-
public Mono<Long> keys(KeyStreamingChannel<K> channel, K pattern) {
275+
public Mono<Long> keys(KeyStreamingChannel<K> channel, String pattern) {
276276

277277
Map<String, Publisher<Long>> publishers = executeOnUpstream(commands -> commands.keys(channel, pattern));
278278
return Flux.merge(publishers.values()).reduce((accu, next) -> accu + next);

src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionKeyAsyncCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public interface NodeSelectionKeyAsyncCommands<K, V> {
229229
* @param pattern the pattern type: patternkey (pattern).
230230
* @return List&lt;K&gt; array-reply list of keys matching {@code pattern}.
231231
*/
232-
AsyncExecutions<List<K>> keys(K pattern);
232+
AsyncExecutions<List<K>> keys(String pattern);
233233

234234
/**
235235
* Find all keys matching the given pattern.
@@ -238,7 +238,7 @@ public interface NodeSelectionKeyAsyncCommands<K, V> {
238238
* @param pattern the pattern.
239239
* @return Long array-reply list of keys matching {@code pattern}.
240240
*/
241-
AsyncExecutions<Long> keys(KeyStreamingChannel<K> channel, K pattern);
241+
AsyncExecutions<Long> keys(KeyStreamingChannel<K> channel, String pattern);
242242

243243
/**
244244
* Atomically transfer a key from a Redis instance to another one.

0 commit comments

Comments
 (0)