Skip to content

Commit 125ee24

Browse files
authored
Modify B[L/R]POP return types (#3440)
1 parent 9d104e8 commit 125ee24

File tree

15 files changed

+121
-154
lines changed

15 files changed

+121
-154
lines changed

docs/jedis5-breaking.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44

55
- Both `bzpopmax(double timeout, byte[]... keys)` and `bzpopmin(double timeout, byte[]... keys)` now return `KeyValue<byte[], Tuple>` (instead of `List<byte[]>`).
66

7+
- Following methods now return `KeyValue<String, String>` instead of `KeyedListElement`:
8+
- `blpop(double timeout, String key)`
9+
- `blpop(double timeout, String... keys)`
10+
- `brpop(double timeout, String key)`
11+
- `brpop(double timeout, String... keys)`
12+
13+
- Following methods now return `KeyValue<byte[], byte[]>` instead of `List<byte[]>`:
14+
- `blpop(double timeout, byte[]... keys)`
15+
- `brpop(double timeout, byte[]... keys)`
16+
717
- `getAgeSeconds()` in `AccessControlLogEntry` now returns `Double` instead of `String`.
818

919
- `graphSlowlog(String graphName)` now returns `List<List<Object>>` (instead of `List<List<String>>`).
1020

1121
- All _payload_ related parameters are removed from _search_ related classes; namely `Document`, `IndexDefinition`, `Query`.
1222

13-
- `KeyedZSetElement` is removed.
23+
- `KeyedZSetElement` class is removed.
24+
25+
- `KeyedListElement` class is removed.
1426

1527
- `STREAM_AUTO_CLAIM_ID_RESPONSE` in BuilderFactory has been renamed to `STREAM_AUTO_CLAIM_JUSTID_RESPONSE`.
1628

src/main/java/redis/clients/jedis/BuilderFactory.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,18 +395,33 @@ public String toString() {
395395
}
396396
};
397397

398-
public static final Builder<KeyedListElement> KEYED_LIST_ELEMENT = new Builder<KeyedListElement>() {
398+
public static final Builder<KeyValue<String, String>> KEYED_ELEMENT = new Builder<KeyValue<String, String>>() {
399399
@Override
400400
@SuppressWarnings("unchecked")
401-
public KeyedListElement build(Object data) {
401+
public KeyValue<String, String> build(Object data) {
402402
if (data == null) return null;
403-
List<byte[]> l = (List<byte[]>) data;
404-
return new KeyedListElement(l.get(0), l.get(1));
403+
List<Object> l = (List<Object>) data;
404+
return KeyValue.of(STRING.build(l.get(0)), STRING.build(l.get(1)));
405+
}
406+
407+
@Override
408+
public String toString() {
409+
return "KeyValue<String, String>";
410+
}
411+
};
412+
413+
public static final Builder<KeyValue<byte[], byte[]>> BINARY_KEYED_ELEMENT = new Builder<KeyValue<byte[], byte[]>>() {
414+
@Override
415+
@SuppressWarnings("unchecked")
416+
public KeyValue<byte[], byte[]> build(Object data) {
417+
if (data == null) return null;
418+
List<Object> l = (List<Object>) data;
419+
return KeyValue.of(BINARY.build(l.get(0)), BINARY.build(l.get(1)));
405420
}
406421

407422
@Override
408423
public String toString() {
409-
return "KeyedListElement";
424+
return "KeyValue<byte[], byte[]>";
410425
}
411426
};
412427

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -852,20 +852,20 @@ public final CommandObject<List<String>> blpop(int timeout, String... keys) {
852852
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.STRING_LIST);
853853
}
854854

855-
public final CommandObject<KeyedListElement> blpop(double timeout, String key) {
856-
return new CommandObject<>(commandArguments(BLPOP).blocking().key(key).add(timeout), BuilderFactory.KEYED_LIST_ELEMENT);
855+
public final CommandObject<KeyValue<String, String>> blpop(double timeout, String key) {
856+
return new CommandObject<>(commandArguments(BLPOP).blocking().key(key).add(timeout), BuilderFactory.KEYED_ELEMENT);
857857
}
858858

859-
public final CommandObject<KeyedListElement> blpop(double timeout, String... keys) {
860-
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.KEYED_LIST_ELEMENT);
859+
public final CommandObject<KeyValue<String, String>> blpop(double timeout, String... keys) {
860+
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.KEYED_ELEMENT);
861861
}
862862

863863
public final CommandObject<List<byte[]>> blpop(int timeout, byte[]... keys) {
864864
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_LIST);
865865
}
866866

867-
public final CommandObject<List<byte[]>> blpop(double timeout, byte[]... keys) {
868-
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_LIST);
867+
public final CommandObject<KeyValue<byte[], byte[]>> blpop(double timeout, byte[]... keys) {
868+
return new CommandObject<>(commandArguments(BLPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_KEYED_ELEMENT);
869869
}
870870

871871
public final CommandObject<List<String>> brpop(int timeout, String key) {
@@ -876,20 +876,20 @@ public final CommandObject<List<String>> brpop(int timeout, String... keys) {
876876
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.STRING_LIST);
877877
}
878878

879-
public final CommandObject<KeyedListElement> brpop(double timeout, String key) {
880-
return new CommandObject<>(commandArguments(BRPOP).blocking().key(key).add(timeout), BuilderFactory.KEYED_LIST_ELEMENT);
879+
public final CommandObject<KeyValue<String, String>> brpop(double timeout, String key) {
880+
return new CommandObject<>(commandArguments(BRPOP).blocking().key(key).add(timeout), BuilderFactory.KEYED_ELEMENT);
881881
}
882882

883-
public final CommandObject<KeyedListElement> brpop(double timeout, String... keys) {
884-
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.KEYED_LIST_ELEMENT);
883+
public final CommandObject<KeyValue<String, String>> brpop(double timeout, String... keys) {
884+
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.KEYED_ELEMENT);
885885
}
886886

887887
public final CommandObject<List<byte[]>> brpop(int timeout, byte[]... keys) {
888888
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_LIST);
889889
}
890890

891-
public final CommandObject<List<byte[]>> brpop(double timeout, byte[]... keys) {
892-
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_LIST);
891+
public final CommandObject<KeyValue<byte[], byte[]>> brpop(double timeout, byte[]... keys) {
892+
return new CommandObject<>(commandArguments(BRPOP).blocking().keys((Object[]) keys).add(timeout), BuilderFactory.BINARY_KEYED_ELEMENT);
893893
}
894894

895895
public final CommandObject<String> rpoplpush(String srckey, String dstkey) {

src/main/java/redis/clients/jedis/Jedis.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@ public List<byte[]> blpop(final int timeout, final byte[]... keys) {
25322532
}
25332533

25342534
@Override
2535-
public List<byte[]> blpop(final double timeout, final byte[]... keys) {
2535+
public KeyValue<byte[], byte[]> blpop(final double timeout, final byte[]... keys) {
25362536
return connection.executeCommand(commandObjects.blpop(timeout, keys));
25372537
}
25382538

@@ -2603,7 +2603,7 @@ public List<byte[]> brpop(final int timeout, final byte[]... keys) {
26032603
}
26042604

26052605
@Override
2606-
public List<byte[]> brpop(final double timeout, final byte[]... keys) {
2606+
public KeyValue<byte[], byte[]> brpop(final double timeout, final byte[]... keys) {
26072607
return connection.executeCommand(commandObjects.brpop(timeout, keys));
26082608
}
26092609

@@ -6926,7 +6926,7 @@ public List<String> blpop(final int timeout, final String... keys) {
69266926
}
69276927

69286928
@Override
6929-
public KeyedListElement blpop(final double timeout, final String... keys) {
6929+
public KeyValue<String, String> blpop(final double timeout, final String... keys) {
69306930
checkIsInMultiOrPipeline();
69316931
return connection.executeCommand(commandObjects.blpop(timeout, keys));
69326932
}
@@ -7000,7 +7000,7 @@ public List<String> brpop(final int timeout, final String... keys) {
70007000
}
70017001

70027002
@Override
7003-
public KeyedListElement brpop(final double timeout, final String... keys) {
7003+
public KeyValue<String, String> brpop(final double timeout, final String... keys) {
70047004
checkIsInMultiOrPipeline();
70057005
return connection.executeCommand(commandObjects.brpop(timeout, keys));
70067006
}
@@ -7048,7 +7048,7 @@ public List<String> blpop(final int timeout, final String key) {
70487048
}
70497049

70507050
@Override
7051-
public KeyedListElement blpop(double timeout, String key) {
7051+
public KeyValue<String, String> blpop(double timeout, String key) {
70527052
checkIsInMultiOrPipeline();
70537053
return connection.executeCommand(commandObjects.blpop(timeout, key));
70547054
}
@@ -7060,7 +7060,7 @@ public List<String> brpop(final int timeout, final String key) {
70607060
}
70617061

70627062
@Override
7063-
public KeyedListElement brpop(double timeout, String key) {
7063+
public KeyValue<String, String> brpop(double timeout, String key) {
70647064
checkIsInMultiOrPipeline();
70657065
return connection.executeCommand(commandObjects.brpop(timeout, key));
70667066
}

src/main/java/redis/clients/jedis/PipelineBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public Response<List<String>> blpop(int timeout, String key) {
551551
}
552552

553553
@Override
554-
public Response<KeyedListElement> blpop(double timeout, String key) {
554+
public Response<KeyValue<String, String>> blpop(double timeout, String key) {
555555
return appendCommand(commandObjects.blpop(timeout, key));
556556
}
557557

@@ -561,7 +561,7 @@ public Response<List<String>> brpop(int timeout, String key) {
561561
}
562562

563563
@Override
564-
public Response<KeyedListElement> brpop(double timeout, String key) {
564+
public Response<KeyValue<String, String>> brpop(double timeout, String key) {
565565
return appendCommand(commandObjects.brpop(timeout, key));
566566
}
567567

@@ -571,7 +571,7 @@ public Response<List<String>> blpop(int timeout, String... keys) {
571571
}
572572

573573
@Override
574-
public Response<KeyedListElement> blpop(double timeout, String... keys) {
574+
public Response<KeyValue<String, String>> blpop(double timeout, String... keys) {
575575
return appendCommand(commandObjects.blpop(timeout, keys));
576576
}
577577

@@ -581,7 +581,7 @@ public Response<List<String>> brpop(int timeout, String... keys) {
581581
}
582582

583583
@Override
584-
public Response<KeyedListElement> brpop(double timeout, String... keys) {
584+
public Response<KeyValue<String, String>> brpop(double timeout, String... keys) {
585585
return appendCommand(commandObjects.brpop(timeout, keys));
586586
}
587587

@@ -2321,7 +2321,7 @@ public Response<List<byte[]>> blpop(int timeout, byte[]... keys) {
23212321
}
23222322

23232323
@Override
2324-
public Response<List<byte[]>> blpop(double timeout, byte[]... keys) {
2324+
public Response<KeyValue<byte[], byte[]>> blpop(double timeout, byte[]... keys) {
23252325
return appendCommand(commandObjects.blpop(timeout, keys));
23262326
}
23272327

@@ -2331,7 +2331,7 @@ public Response<List<byte[]>> brpop(int timeout, byte[]... keys) {
23312331
}
23322332

23332333
@Override
2334-
public Response<List<byte[]>> brpop(double timeout, byte[]... keys) {
2334+
public Response<KeyValue<byte[], byte[]>> brpop(double timeout, byte[]... keys) {
23352335
return appendCommand(commandObjects.brpop(timeout, keys));
23362336
}
23372337

src/main/java/redis/clients/jedis/TransactionBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ public Response<List<String>> blpop(int timeout, String key) {
708708
}
709709

710710
@Override
711-
public Response<KeyedListElement> blpop(double timeout, String key) {
711+
public Response<KeyValue<String, String>> blpop(double timeout, String key) {
712712
return appendCommand(commandObjects.blpop(timeout, key));
713713
}
714714

@@ -718,7 +718,7 @@ public Response<List<String>> brpop(int timeout, String key) {
718718
}
719719

720720
@Override
721-
public Response<KeyedListElement> brpop(double timeout, String key) {
721+
public Response<KeyValue<String, String>> brpop(double timeout, String key) {
722722
return appendCommand(commandObjects.brpop(timeout, key));
723723
}
724724

@@ -728,7 +728,7 @@ public Response<List<String>> blpop(int timeout, String... keys) {
728728
}
729729

730730
@Override
731-
public Response<KeyedListElement> blpop(double timeout, String... keys) {
731+
public Response<KeyValue<String, String>> blpop(double timeout, String... keys) {
732732
return appendCommand(commandObjects.blpop(timeout, keys));
733733
}
734734

@@ -738,7 +738,7 @@ public Response<List<String>> brpop(int timeout, String... keys) {
738738
}
739739

740740
@Override
741-
public Response<KeyedListElement> brpop(double timeout, String... keys) {
741+
public Response<KeyValue<String, String>> brpop(double timeout, String... keys) {
742742
return appendCommand(commandObjects.brpop(timeout, keys));
743743
}
744744

@@ -2484,7 +2484,7 @@ public Response<List<byte[]>> blpop(int timeout, byte[]... keys) {
24842484
}
24852485

24862486
@Override
2487-
public Response<List<byte[]>> blpop(double timeout, byte[]... keys) {
2487+
public Response<KeyValue<byte[], byte[]>> blpop(double timeout, byte[]... keys) {
24882488
return appendCommand(commandObjects.blpop(timeout, keys));
24892489
}
24902490

@@ -2494,7 +2494,7 @@ public Response<List<byte[]>> brpop(int timeout, byte[]... keys) {
24942494
}
24952495

24962496
@Override
2497-
public Response<List<byte[]>> brpop(double timeout, byte[]... keys) {
2497+
public Response<KeyValue<byte[], byte[]>> brpop(double timeout, byte[]... keys) {
24982498
return appendCommand(commandObjects.brpop(timeout, keys));
24992499
}
25002500

src/main/java/redis/clients/jedis/UnifiedJedis.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ public List<String> blpop(int timeout, String key) {
12301230
}
12311231

12321232
@Override
1233-
public KeyedListElement blpop(double timeout, String key) {
1233+
public KeyValue<String, String> blpop(double timeout, String key) {
12341234
return executeCommand(commandObjects.blpop(timeout, key));
12351235
}
12361236

@@ -1240,7 +1240,7 @@ public List<String> brpop(int timeout, String key) {
12401240
}
12411241

12421242
@Override
1243-
public KeyedListElement brpop(double timeout, String key) {
1243+
public KeyValue<String, String> brpop(double timeout, String key) {
12441244
return executeCommand(commandObjects.brpop(timeout, key));
12451245
}
12461246

@@ -1250,7 +1250,7 @@ public List<String> blpop(int timeout, String... keys) {
12501250
}
12511251

12521252
@Override
1253-
public KeyedListElement blpop(double timeout, String... keys) {
1253+
public KeyValue<String, String> blpop(double timeout, String... keys) {
12541254
return executeCommand(commandObjects.blpop(timeout, keys));
12551255
}
12561256

@@ -1260,7 +1260,7 @@ public List<String> brpop(int timeout, String... keys) {
12601260
}
12611261

12621262
@Override
1263-
public KeyedListElement brpop(double timeout, String... keys) {
1263+
public KeyValue<String, String> brpop(double timeout, String... keys) {
12641264
return executeCommand(commandObjects.brpop(timeout, keys));
12651265
}
12661266

@@ -1270,7 +1270,7 @@ public List<byte[]> blpop(int timeout, byte[]... keys) {
12701270
}
12711271

12721272
@Override
1273-
public List<byte[]> blpop(double timeout, byte[]... keys) {
1273+
public KeyValue<byte[], byte[]> blpop(double timeout, byte[]... keys) {
12741274
return executeCommand(commandObjects.blpop(timeout, keys));
12751275
}
12761276

@@ -1280,7 +1280,7 @@ public List<byte[]> brpop(int timeout, byte[]... keys) {
12801280
}
12811281

12821282
@Override
1283-
public List<byte[]> brpop(double timeout, byte[]... keys) {
1283+
public KeyValue<byte[], byte[]> brpop(double timeout, byte[]... keys) {
12841284
return executeCommand(commandObjects.brpop(timeout, keys));
12851285
}
12861286

src/main/java/redis/clients/jedis/commands/ListBinaryCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public interface ListBinaryCommands {
4747

4848
List<byte[]> blpop(int timeout, byte[]... keys);
4949

50-
List<byte[]> blpop(double timeout, byte[]... keys);
50+
KeyValue<byte[], byte[]> blpop(double timeout, byte[]... keys);
5151

5252
List<byte[]> brpop(int timeout, byte[]... keys);
5353

54-
List<byte[]> brpop(double timeout, byte[]... keys);
54+
KeyValue<byte[], byte[]> brpop(double timeout, byte[]... keys);
5555

5656
byte[] rpoplpush(byte[] srckey, byte[] dstkey);
5757

src/main/java/redis/clients/jedis/commands/ListCommands.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import redis.clients.jedis.args.ListDirection;
66
import redis.clients.jedis.args.ListPosition;
77
import redis.clients.jedis.params.LPosParams;
8-
import redis.clients.jedis.resps.KeyedListElement;
98
import redis.clients.jedis.util.KeyValue;
109

1110
public interface ListCommands {
@@ -303,13 +302,13 @@ public interface ListCommands {
303302
* seconds to block. A timeout of zero can be used to block indefinitely.
304303
* @param keys
305304
*/
306-
KeyedListElement blpop(double timeout, String... keys);
305+
KeyValue<String, String> blpop(double timeout, String... keys);
307306

308307

309308
/**
310309
* @see ListCommands#blpop(double, String...)
311310
*/
312-
KeyedListElement blpop(double timeout, String key);
311+
KeyValue<String, String> blpop(double timeout, String key);
313312

314313
/**
315314
* The blocking version of {@link ListCommands#rpop(String)} RPOP} because it blocks the connection
@@ -334,12 +333,12 @@ public interface ListCommands {
334333
* seconds to block. A timeout of zero can be used to block indefinitely.
335334
* @param keys
336335
*/
337-
KeyedListElement brpop(double timeout, String... keys);
336+
KeyValue<String, String> brpop(double timeout, String... keys);
338337

339338
/**
340339
* @see ListCommands#brpop(double, String...)
341340
*/
342-
KeyedListElement brpop(double timeout, String key);
341+
KeyValue<String, String> brpop(double timeout, String key);
343342

344343
/**
345344
* Atomically return and remove the last (tail) element of the srckey list, and push the element

0 commit comments

Comments
 (0)