25
25
import java .util .Collections ;
26
26
import java .util .List ;
27
27
import java .util .Optional ;
28
+ import java .util .concurrent .TimeUnit ;
28
29
import java .util .function .Function ;
29
30
30
31
import org .reactivestreams .Publisher ;
31
-
32
32
import org .springframework .data .domain .Range ;
33
33
import org .springframework .data .domain .Sort .Direction ;
34
34
import org .springframework .data .redis .connection .ReactiveRedisConnection .CommandResponse ;
@@ -163,8 +163,7 @@ public ZAddCommand incr() {
163
163
}
164
164
165
165
/**
166
- * Applies {@literal GT} mode. Constructs a new command
167
- * instance with all previously configured properties.
166
+ * Applies {@literal GT} mode. Constructs a new command instance with all previously configured properties.
168
167
*
169
168
* @return a new {@link ZAddCommand} with {@literal incr} applied.
170
169
* @since 2.5
@@ -174,8 +173,7 @@ public ZAddCommand gt() {
174
173
}
175
174
176
175
/**
177
- * Applies {@literal LT} mode. Constructs a new command
178
- * instance with all previously configured properties.
176
+ * Applies {@literal LT} mode. Constructs a new command instance with all previously configured properties.
179
177
*
180
178
* @return a new {@link ZAddCommand} with {@literal incr} applied.
181
179
* @since 2.5
@@ -206,7 +204,6 @@ public boolean isIncr() {
206
204
}
207
205
208
206
/**
209
- *
210
207
* @return {@literal true} if {@literal GT} is set.
211
208
* @since 2.5
212
209
*/
@@ -1337,15 +1334,18 @@ class BZPopCommand extends KeyCommand {
1337
1334
1338
1335
private final PopDirection direction ;
1339
1336
1340
- private final Duration timeout ;
1337
+ private final @ Nullable TimeUnit timeUnit ;
1338
+ private final @ Nullable Long timeout ;
1341
1339
1342
1340
private final long count ;
1343
1341
1344
- private BZPopCommand (@ Nullable ByteBuffer key , Duration timeout , long count , PopDirection direction ) {
1342
+ private BZPopCommand (@ Nullable ByteBuffer key , @ Nullable Long timeout , @ Nullable TimeUnit timeUnit , long count ,
1343
+ PopDirection direction ) {
1345
1344
1346
1345
super (key );
1347
1346
this .count = count ;
1348
1347
this .timeout = timeout ;
1348
+ this .timeUnit = timeUnit ;
1349
1349
this .direction = direction ;
1350
1350
}
1351
1351
@@ -1355,7 +1355,7 @@ private BZPopCommand(@Nullable ByteBuffer key, Duration timeout, long count, Pop
1355
1355
* @return a new {@link BZPopCommand} for min pop ({@literal ZPOPMIN}).
1356
1356
*/
1357
1357
public static BZPopCommand min () {
1358
- return new BZPopCommand (null , null , 0 , PopDirection .MIN );
1358
+ return new BZPopCommand (null , null , null , 0 , PopDirection .MIN );
1359
1359
}
1360
1360
1361
1361
/**
@@ -1364,7 +1364,7 @@ public static BZPopCommand min() {
1364
1364
* @return a new {@link BZPopCommand} for max pop ({@literal ZPOPMAX}).
1365
1365
*/
1366
1366
public static BZPopCommand max () {
1367
- return new BZPopCommand (null , null , 0 , PopDirection .MAX );
1367
+ return new BZPopCommand (null , null , null , 0 , PopDirection .MAX );
1368
1368
}
1369
1369
1370
1370
/**
@@ -1377,7 +1377,7 @@ public BZPopCommand from(ByteBuffer key) {
1377
1377
1378
1378
Assert .notNull (key , "Key must not be null!" );
1379
1379
1380
- return new BZPopCommand (key , timeout , count , direction );
1380
+ return new BZPopCommand (key , timeout , timeUnit , count , direction );
1381
1381
}
1382
1382
1383
1383
/**
@@ -1387,7 +1387,7 @@ public BZPopCommand from(ByteBuffer key) {
1387
1387
* @return a new {@link BZPopCommand} with {@literal value} applied.
1388
1388
*/
1389
1389
public BZPopCommand count (long count ) {
1390
- return new BZPopCommand (getKey (), timeout , count , direction );
1390
+ return new BZPopCommand (getKey (), timeout , timeUnit , count , direction );
1391
1391
}
1392
1392
1393
1393
/**
@@ -1400,7 +1400,21 @@ public BZPopCommand blockingFor(Duration timeout) {
1400
1400
1401
1401
Assert .notNull (timeout , "Timeout must not be null!" );
1402
1402
1403
- return new BZPopCommand (getKey (), timeout , count , direction );
1403
+ return blockingFor (timeout .toMillis (), TimeUnit .MILLISECONDS );
1404
+ }
1405
+
1406
+ /**
1407
+ * Applies a {@link Duration timeout}. Constructs a new command instance with all previously configured properties.
1408
+ *
1409
+ * @param timeout value.
1410
+ * @param timeout must not be {@literal null}.
1411
+ * @return a new {@link BZPopCommand} with {@link Duration timeout} applied.
1412
+ */
1413
+ public BZPopCommand blockingFor (long timeout , TimeUnit timeUnit ) {
1414
+
1415
+ Assert .notNull (timeUnit , "TimeUnit must not be null!" );
1416
+
1417
+ return new BZPopCommand (getKey (), timeout , timeUnit , count , direction );
1404
1418
}
1405
1419
1406
1420
/**
@@ -1410,10 +1424,16 @@ public PopDirection getDirection() {
1410
1424
return direction ;
1411
1425
}
1412
1426
1413
- public Duration getTimeout () {
1427
+ @ Nullable
1428
+ public Long getTimeout () {
1414
1429
return timeout ;
1415
1430
}
1416
1431
1432
+ @ Nullable
1433
+ public TimeUnit getTimeUnit () {
1434
+ return timeUnit ;
1435
+ }
1436
+
1417
1437
public long getCount () {
1418
1438
return count ;
1419
1439
}
@@ -1664,7 +1684,7 @@ public static ZMScoreCommand scoreOf(ByteBuffer member) {
1664
1684
/**
1665
1685
* Creates a new {@link ZMScoreCommand} given a {@link List members}.
1666
1686
*
1667
- * @param member must not be {@literal null}.
1687
+ * @param members must not be {@literal null}.
1668
1688
* @return a new {@link ZMScoreCommand} for {@link List} of members.
1669
1689
*/
1670
1690
public static ZMScoreCommand scoreOf (Collection <ByteBuffer > members ) {
0 commit comments