Skip to content

Commit b1c2161

Browse files
Though it works I'm not fully convinced the breaking api change is reasonable
1 parent c83bb2f commit b1c2161

22 files changed

+138
-115
lines changed

src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,17 @@ public void bgReWriteAof() {
261261
}
262262

263263
@Override
264-
public List<byte[]> bLPop(int timeout, byte[]... keys) {
264+
public List<byte[]> bLPop(double timeout, byte[]... keys) {
265265
return convertAndReturn(delegate.bLPop(timeout, keys), Converters.identityConverter());
266266
}
267267

268268
@Override
269-
public List<byte[]> bRPop(int timeout, byte[]... keys) {
269+
public List<byte[]> bRPop(double timeout, byte[]... keys) {
270270
return convertAndReturn(delegate.bRPop(timeout, keys), Converters.identityConverter());
271271
}
272272

273273
@Override
274-
public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
274+
public byte[] bRPopLPush(double timeout, byte[] srcKey, byte[] dstKey) {
275275
return convertAndReturn(delegate.bRPopLPush(timeout, srcKey, dstKey), Converters.identityConverter());
276276
}
277277

@@ -1421,17 +1421,17 @@ public Long append(String key, String value) {
14211421
}
14221422

14231423
@Override
1424-
public List<String> bLPop(int timeout, String... keys) {
1424+
public List<String> bLPop(double timeout, String... keys) {
14251425
return convertAndReturn(delegate.bLPop(timeout, serializeMulti(keys)), byteListToStringList);
14261426
}
14271427

14281428
@Override
1429-
public List<String> bRPop(int timeout, String... keys) {
1429+
public List<String> bRPop(double timeout, String... keys) {
14301430
return convertAndReturn(delegate.bRPop(timeout, serializeMulti(keys)), byteListToStringList);
14311431
}
14321432

14331433
@Override
1434-
public String bRPopLPush(int timeout, String srcKey, String dstKey) {
1434+
public String bRPopLPush(double timeout, String srcKey, String dstKey) {
14351435
return convertAndReturn(delegate.bRPopLPush(timeout, serialize(srcKey), serialize(dstKey)), bytesToString);
14361436
}
14371437

@@ -2009,12 +2009,12 @@ public Long zLexCount(byte[] key, org.springframework.data.domain.Range<byte[]>
20092009
}
20102010

20112011
@Override
2012-
public @Nullable Tuple bZPopMin(byte[] key, long timeout, TimeUnit unit) {
2012+
public @Nullable Tuple bZPopMin(byte[] key, double timeout, TimeUnit unit) {
20132013
return delegate.bZPopMin(key, timeout, unit);
20142014
}
20152015

20162016
@Override
2017-
public @Nullable StringTuple bZPopMin(String key, long timeout, TimeUnit unit) {
2017+
public @Nullable StringTuple bZPopMin(String key, double timeout, TimeUnit unit) {
20182018
return convertAndReturn(delegate.bZPopMin(serialize(key), timeout, unit), tupleConverter);
20192019
}
20202020

@@ -2039,12 +2039,12 @@ public Long zLexCount(byte[] key, org.springframework.data.domain.Range<byte[]>
20392039
}
20402040

20412041
@Override
2042-
public @Nullable Tuple bZPopMax(byte[] key, long timeout, TimeUnit unit) {
2042+
public @Nullable Tuple bZPopMax(byte[] key, double timeout, TimeUnit unit) {
20432043
return delegate.bZPopMax(key, timeout, unit);
20442044
}
20452045

20462046
@Override
2047-
public @Nullable StringTuple bZPopMax(String key, long timeout, TimeUnit unit) {
2047+
public @Nullable StringTuple bZPopMax(String key, double timeout, TimeUnit unit) {
20482048
return convertAndReturn(delegate.bZPopMax(serialize(key), timeout, unit), tupleConverter);
20492049
}
20502050

src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,14 @@ default List<byte[]> rPop(byte[] key, long count) {
821821
/** @deprecated in favor of {@link RedisConnection#listCommands()}}. */
822822
@Override
823823
@Deprecated
824-
default List<byte[]> bLPop(int timeout, byte[]... keys) {
824+
default List<byte[]> bLPop(double timeout, byte[]... keys) {
825825
return listCommands().bLPop(timeout, keys);
826826
}
827827

828828
/** @deprecated in favor of {@link RedisConnection#listCommands()}}. */
829829
@Override
830830
@Deprecated
831-
default List<byte[]> bRPop(int timeout, byte[]... keys) {
831+
default List<byte[]> bRPop(double timeout, byte[]... keys) {
832832
return listCommands().bRPop(timeout, keys);
833833
}
834834

@@ -842,7 +842,7 @@ default byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
842842
/** @deprecated in favor of {@link RedisConnection#listCommands()}}. */
843843
@Override
844844
@Deprecated
845-
default byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
845+
default byte[] bRPopLPush(double timeout, byte[] srcKey, byte[] dstKey) {
846846
return listCommands().bRPopLPush(timeout, srcKey, dstKey);
847847
}
848848

@@ -1028,7 +1028,7 @@ default Set<Tuple> zPopMin(byte[] key, long count) {
10281028
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
10291029
@Override
10301030
@Deprecated
1031-
default Tuple bZPopMin(byte[] key, long timeout, TimeUnit unit) {
1031+
default Tuple bZPopMin(byte[] key, double timeout, TimeUnit unit) {
10321032
return zSetCommands().bZPopMin(key, timeout, unit);
10331033
}
10341034

@@ -1049,7 +1049,7 @@ default Set<Tuple> zPopMax(byte[] key, long count) {
10491049
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
10501050
@Override
10511051
@Deprecated
1052-
default Tuple bZPopMax(byte[] key, long timeout, TimeUnit unit) {
1052+
default Tuple bZPopMax(byte[] key, double timeout, TimeUnit unit) {
10531053
return zSetCommands().bZPopMax(key, timeout, unit);
10541054
}
10551055

src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ private HashExpireCommand(@Nullable ByteBuffer key, List<ByteBuffer> fields, Exp
872872
* @param unit the unit of measure for the {@code timeout}.
873873
* @return new instance of {@link HashExpireCommand}.
874874
*/
875-
public static HashExpireCommand expire(List<ByteBuffer> fields, long timeout, TimeUnit unit) {
875+
public static HashExpireCommand expire(List<ByteBuffer> fields, double timeout, TimeUnit unit) {
876876

877877
Assert.notNull(fields, "Field must not be null");
878878
return expire(fields, Expiration.from(timeout, unit));

src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,11 +1744,11 @@ class BZPopCommand extends KeyCommand {
17441744
private final PopDirection direction;
17451745

17461746
private final @Nullable TimeUnit timeUnit;
1747-
private final @Nullable Long timeout;
1747+
private final @Nullable Double timeout;
17481748

17491749
private final long count;
17501750

1751-
private BZPopCommand(@Nullable ByteBuffer key, @Nullable Long timeout, @Nullable TimeUnit timeUnit, long count,
1751+
private BZPopCommand(@Nullable ByteBuffer key, @Nullable Double timeout, @Nullable TimeUnit timeUnit, long count,
17521752
PopDirection direction) {
17531753

17541754
super(key);
@@ -1809,7 +1809,7 @@ public BZPopCommand blockingFor(Duration timeout) {
18091809

18101810
Assert.notNull(timeout, "Timeout must not be null");
18111811

1812-
return blockingFor(timeout.toMillis(), TimeUnit.MILLISECONDS);
1812+
return blockingFor((double)timeout.toMillis(), TimeUnit.MILLISECONDS);
18131813
}
18141814

18151815
/**
@@ -1819,7 +1819,7 @@ public BZPopCommand blockingFor(Duration timeout) {
18191819
* @param timeUnit must not be {@literal null}.
18201820
* @return a new {@link BZPopCommand} with {@link Duration timeout} applied.
18211821
*/
1822-
public BZPopCommand blockingFor(long timeout, TimeUnit timeUnit) {
1822+
public BZPopCommand blockingFor(Double timeout, TimeUnit timeUnit) {
18231823

18241824
Assert.notNull(timeUnit, "TimeUnit must not be null");
18251825

@@ -1833,7 +1833,7 @@ public PopDirection getDirection() {
18331833
return direction;
18341834
}
18351835

1836-
public @Nullable Long getTimeout() {
1836+
public @Nullable Double getTimeout() {
18371837
return timeout;
18381838
}
18391839

src/main/java/org/springframework/data/redis/connection/RedisListCommands.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ byte[] bLMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonN
301301
* @see #lPop(byte[])
302302
*/
303303
@Nullable
304-
List<byte @NonNull []> bLPop(int timeout, byte @NonNull [] @NonNull... keys);
304+
List<byte @NonNull []> bLPop(double timeout, byte @NonNull [] @NonNull... keys);
305305

306306
/**
307307
* Removes and returns last element from lists stored at {@code keys}. <br>
@@ -314,7 +314,7 @@ byte[] bLMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonN
314314
* @see <a href="https://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
315315
* @see #rPop(byte[])
316316
*/
317-
List<byte @NonNull []> bRPop(int timeout, byte @NonNull [] @NonNull... keys);
317+
List<byte @NonNull []> bRPop(double timeout, byte @NonNull [] @NonNull... keys);
318318

319319
/**
320320
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
@@ -337,5 +337,5 @@ byte[] bLMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonN
337337
* @see <a href="https://redis.io/commands/brpoplpush">Redis Documentation: BRPOPLPUSH</a>
338338
* @see #rPopLPush(byte[], byte[])
339339
*/
340-
byte[] bRPopLPush(int timeout, byte @NonNull [] srcKey, byte @NonNull [] dstKey);
340+
byte[] bRPopLPush(double timeout, byte @NonNull [] srcKey, byte @NonNull [] dstKey);
341341
}

src/main/java/org/springframework/data/redis/connection/RedisServerCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,6 @@ default Long time() {
298298
* @see <a href="https://redis.io/commands/migrate">Redis Documentation: MIGRATE</a>
299299
*/
300300
void migrate(byte @NonNull [] key, @NonNull RedisNode target, int dbIndex, @Nullable MigrateOption option,
301-
long timeout);
301+
long timeout);
302302

303303
}

src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ default Long zCount(byte @NonNull [] key, double min, double max) {
854854
* @see <a href="https://redis.io/commands/bzpopmin">Redis Documentation: BZPOPMIN</a>
855855
* @since 2.6
856856
*/
857-
Tuple bZPopMin(byte @NonNull [] key, long timeout, @NonNull TimeUnit unit);
857+
Tuple bZPopMin(byte @NonNull [] key, double timeout, @NonNull TimeUnit unit);
858858

859859
/**
860860
* Remove and return the value with its score having the highest score from sorted set at {@code key}.
@@ -888,7 +888,7 @@ default Long zCount(byte @NonNull [] key, double min, double max) {
888888
* @see <a href="https://redis.io/commands/bzpopmax">Redis Documentation: BZPOPMAX</a>
889889
* @since 2.6
890890
*/
891-
Tuple bZPopMax(byte @NonNull [] key, long timeout, @NonNull TimeUnit unit);
891+
Tuple bZPopMax(byte @NonNull [] key, double timeout, @NonNull TimeUnit unit);
892892

893893
/**
894894
* Get the size of sorted set with {@code key}.

src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,9 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
10131013
* @param keys must not be {@literal null}.
10141014
* @return
10151015
* @see <a href="https://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
1016-
* @see RedisListCommands#bLPop(int, byte[]...)
1016+
* @see RedisListCommands#bLPop(double, byte[]...)
10171017
*/
1018-
List<String> bLPop(int timeout, @NonNull String @NonNull... keys);
1018+
List<String> bLPop(double timeout, @NonNull String @NonNull... keys);
10191019

10201020
/**
10211021
* Removes and returns last element from lists stored at {@code keys} (see: {@link #rPop(byte[])}). <br>
@@ -1025,9 +1025,9 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
10251025
* @param keys must not be {@literal null}.
10261026
* @return
10271027
* @see <a href="https://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
1028-
* @see RedisListCommands#bRPop(int, byte[]...)
1028+
* @see RedisListCommands#bRPop(double, byte[]...)
10291029
*/
1030-
List<String> bRPop(int timeout, @NonNull String @NonNull... keys);
1030+
List<String> bRPop(double timeout, @NonNull String @NonNull... keys);
10311031

10321032
/**
10331033
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
@@ -1050,9 +1050,9 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
10501050
* @param dstKey must not be {@literal null}.
10511051
* @return
10521052
* @see <a href="https://redis.io/commands/brpoplpush">Redis Documentation: BRPOPLPUSH</a>
1053-
* @see RedisListCommands#bRPopLPush(int, byte[], byte[])
1053+
* @see RedisListCommands#bRPopLPush(double, byte[], byte[])
10541054
*/
1055-
String bRPopLPush(int timeout, @NonNull String srcKey, @NonNull String dstKey);
1055+
String bRPopLPush(double timeout, @NonNull String srcKey, @NonNull String dstKey);
10561056

10571057
// -------------------------------------------------------------------------
10581058
// Methods dealing with Redis Sets
@@ -1616,7 +1616,7 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
16161616
* @see <a href="https://redis.io/commands/bzpopmin">Redis Documentation: BZPOPMIN</a>
16171617
* @since 2.6
16181618
*/
1619-
StringTuple bZPopMin(@NonNull String key, long timeout, @NonNull TimeUnit unit);
1619+
StringTuple bZPopMin(@NonNull String key, double timeout, @NonNull TimeUnit unit);
16201620

16211621
/**
16221622
* Remove and return the value with its score having the highest score from sorted set at {@code key}.
@@ -1650,7 +1650,7 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
16501650
* @see <a href="https://redis.io/commands/bzpopmax">Redis Documentation: BZPOPMAX</a>
16511651
* @since 2.6
16521652
*/
1653-
StringTuple bZPopMax(@NonNull String key, long timeout, @NonNull TimeUnit unit);
1653+
StringTuple bZPopMax(@NonNull String key, double timeout, @NonNull TimeUnit unit);
16541654

16551655
/**
16561656
* Get the size of sorted set with {@code key}.

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,43 +294,43 @@ public byte[] rPop(byte[] key) {
294294
}
295295

296296
@Override
297-
public List<byte @NonNull []> bLPop(int timeout, byte @NonNull [] @NonNull... keys) {
297+
public List<byte @NonNull []> bLPop(double timeout, byte @NonNull [] @NonNull... keys) {
298298

299299
Assert.notNull(keys, "Key must not be null");
300300
Assert.noNullElements(keys, "Keys must not contain null elements");
301301
302302
if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
303303
try {
304-
return connection.getCluster().blpop(timeout, keys);
304+
return JedisConverters.kvToList(connection.getCluster().blpop(timeout, keys));
305305
} catch (Exception ex) {
306306
throw convertJedisAccessException(ex);
307307
}
308308
}
309309
310310
return connection.getClusterCommandExecutor()
311311
.executeMultiKeyCommand(
312-
(JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> client.blpop(timeout, key),
312+
(JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> JedisConverters.kvToList(client.blpop(timeout, key)),
313313
Arrays.asList(keys))
314314
.getFirstNonNullNotEmptyOrDefault(Collections.<byte[]> emptyList());
315315
}
316316
317317
@Override
318-
public List<byte @NonNull []> bRPop(int timeout, byte @NonNull [] @NonNull... keys) {
318+
public List<byte @NonNull []> bRPop(double timeout, byte @NonNull [] @NonNull... keys) {
319319
320320
Assert.notNull(keys, "Key must not be null");
321321
Assert.noNullElements(keys, "Keys must not contain null elements");
322322

323323
if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
324324
try {
325-
return connection.getCluster().brpop(timeout, keys);
325+
return JedisConverters.kvToList(connection.getCluster().brpop(timeout, keys));
326326
} catch (Exception ex) {
327327
throw convertJedisAccessException(ex);
328328
}
329329
}
330330

331331
return connection.getClusterCommandExecutor()
332332
.executeMultiKeyCommand(
333-
(JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> client.brpop(timeout, key),
333+
(JedisMultiKeyClusterCommandCallback<List<byte[]>>) (client, key) -> JedisConverters.kvToList(client.brpop(timeout, key)),
334334
Arrays.asList(keys))
335335
.getFirstNonNullNotEmptyOrDefault(Collections.<byte[]> emptyList());
336336
}
@@ -355,14 +355,14 @@ public byte[] rPopLPush(byte @NonNull [] srcKey, byte @NonNull [] dstKey) {
355355
}
356356

357357
@Override
358-
public byte[] bRPopLPush(int timeout, byte @NonNull [] srcKey, byte @NonNull [] dstKey) {
358+
public byte[] bRPopLPush(double timeout, byte @NonNull [] srcKey, byte @NonNull [] dstKey) {
359359

360360
Assert.notNull(srcKey, "Source key must not be null");
361361
Assert.notNull(dstKey, "Destination key must not be null");
362362

363363
if (ClusterSlotHashUtil.isSameSlotForAllKeys(srcKey, dstKey)) {
364364
try {
365-
return connection.getCluster().brpoplpush(srcKey, dstKey, timeout);
365+
return connection.getCluster().brpoplpush(srcKey, dstKey, Double.valueOf(timeout).intValue());
366366
} catch (Exception ex) {
367367
throw convertJedisAccessException(ex);
368368
}

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ public Set<Tuple> zPopMin(byte @NonNull [] key, long count) {
349349
}
350350

351351
@Override
352-
public Tuple bZPopMin(byte @NonNull [] key, long timeout, @NonNull TimeUnit unit) {
352+
public Tuple bZPopMin(byte @NonNull [] key, double timeout, @NonNull TimeUnit unit) {
353353

354354
Assert.notNull(key, "Key must not be null");
355355
Assert.notNull(unit, "TimeUnit must not be null");
356356

357357
try {
358-
return toTuple(connection.getCluster().bzpopmin(JedisConverters.toSeconds(timeout, unit), key));
358+
return toTuple(connection.getCluster().bzpopmin(timeout, key));
359359
} catch (Exception ex) {
360360
throw convertJedisAccessException(ex);
361361
}
@@ -387,13 +387,13 @@ public Set<Tuple> zPopMax(byte @NonNull [] key, long count) {
387387
}
388388

389389
@Override
390-
public Tuple bZPopMax(byte @NonNull [] key, long timeout, @NonNull TimeUnit unit) {
390+
public Tuple bZPopMax(byte @NonNull [] key, double timeout, @NonNull TimeUnit unit) {
391391

392392
Assert.notNull(key, "Key must not be null");
393393
Assert.notNull(unit, "TimeUnit must not be null");
394394

395395
try {
396-
return toTuple(connection.getCluster().bzpopmax(JedisConverters.toSeconds(timeout, unit), key));
396+
return toTuple(connection.getCluster().bzpopmax(timeout, key));
397397
} catch (Exception ex) {
398398
throw convertJedisAccessException(ex);
399399
}

0 commit comments

Comments
 (0)