Skip to content

Commit 06f3591

Browse files
christophstroblmp911de
authored andcommitted
Polishing.
Update javadoc and format sources. See spring-projects#3054.
1 parent c6ba95f commit 06f3591

15 files changed

+432
-294
lines changed

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

+38
Original file line numberDiff line numberDiff line change
@@ -865,22 +865,52 @@ private ExpireCommand(@Nullable ByteBuffer key, List<ByteBuffer> fields, Expirat
865865
this.options = options;
866866
}
867867

868+
/**
869+
* Creates a new {@link ExpireCommand}.
870+
*
871+
* @param fields the {@code field} names to apply expiration to
872+
* @param timeout the actual timeout
873+
* @param unit the unit of measure for the {@code timeout}.
874+
* @return new instance of {@link ExpireCommand}.
875+
*/
868876
public static ExpireCommand expire(List<ByteBuffer> fields, long timeout, TimeUnit unit) {
869877

870878
Assert.notNull(fields, "Field must not be null");
871879
return expire(fields, Expiration.from(timeout, unit));
872880
}
873881

882+
/**
883+
* Creates a new {@link ExpireCommand}.
884+
*
885+
* @param fields the {@code field} names to apply expiration to.
886+
* @param ttl the actual timeout.
887+
* @return new instance of {@link ExpireCommand}.
888+
*/
874889
public static ExpireCommand expire(List<ByteBuffer> fields, Duration ttl) {
875890

876891
Assert.notNull(fields, "Field must not be null");
877892
return expire(fields, Expiration.from(ttl));
878893
}
879894

895+
/**
896+
* Creates a new {@link ExpireCommand}.
897+
*
898+
* @param fields the {@code field} names to apply expiration to
899+
* @param expiration the {@link Expiration} to apply to the given {@literal fields}.
900+
* @return new instance of {@link ExpireCommand}.
901+
*/
880902
public static ExpireCommand expire(List<ByteBuffer> fields, Expiration expiration) {
881903
return new ExpireCommand(null, fields, expiration, FieldExpirationOptions.none());
882904
}
883905

906+
/**
907+
* Creates a new {@link ExpireCommand}.
908+
*
909+
* @param fields the {@code field} names to apply expiration to
910+
* @param ttl the unix point in time when to expire the given {@literal fields}.
911+
* @param precision can be {@link TimeUnit#SECONDS} or {@link TimeUnit#MILLISECONDS}.
912+
* @return new instance of {@link ExpireCommand}.
913+
*/
884914
public static ExpireCommand expireAt(List<ByteBuffer> fields, Instant ttl, TimeUnit precision) {
885915

886916
if (precision.compareTo(TimeUnit.MILLISECONDS) > 0) {
@@ -890,10 +920,18 @@ public static ExpireCommand expireAt(List<ByteBuffer> fields, Instant ttl, TimeU
890920
return expire(fields, Expiration.unixTimestamp(ttl.toEpochMilli(), TimeUnit.MILLISECONDS));
891921
}
892922

923+
/**
924+
* @param key the {@literal key} from which to expire the {@literal fields} from.
925+
* @return new instance of {@link ExpireCommand}.
926+
*/
893927
public ExpireCommand from(ByteBuffer key) {
894928
return new ExpireCommand(key, getFields(), expiration, options);
895929
}
896930

931+
/**
932+
* @param options additional options to be sent along with the command.
933+
* @return new instance of {@link ExpireCommand}.
934+
*/
897935
public ExpireCommand withOptions(FieldExpirationOptions options) {
898936
return new ExpireCommand(getKey(), getFields(), getExpiration(), options);
899937
}

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

+35-20
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,34 @@ public interface RedisHashCommands {
255255
@Nullable
256256
Long hStrLen(byte[] key, byte[] field);
257257

258+
/**
259+
* Apply a given {@link org.springframework.data.redis.core.types.Expiration} to the given {@literal fields}.
260+
*
261+
* @param key must not be {@literal null}.
262+
* @param expiration the {@link org.springframework.data.redis.core.types.Expiration} to apply.
263+
* @param fields the names of the {@literal fields} to apply the {@literal expiration} to.
264+
* @return a {@link List} holding the command result for each field in order - {@code 2} indicating the specific field
265+
* is deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration
266+
* time is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no
267+
* such field;
268+
* @since 3.5
269+
*/
258270
default @Nullable List<Long> applyExpiration(byte[] key,
259271
org.springframework.data.redis.core.types.Expiration expiration, byte[]... fields) {
260272
return applyExpiration(key, expiration, FieldExpirationOptions.none(), fields);
261273
}
262274

275+
/**
276+
* @param key must not be {@literal null}.
277+
* @param expiration the {@link org.springframework.data.redis.core.types.Expiration} to apply.
278+
* @param options additional options to be sent along with the command.
279+
* @param fields the names of the {@literal fields} to apply the {@literal expiration} to.
280+
* @return a {@link List} holding the command result for each field in order - {@code 2} indicating the specific field
281+
* is deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration
282+
* time is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT
283+
* condition is not met); {@code -2} indicating there is no such field;
284+
* @since 3.5
285+
*/
263286
@Nullable
264287
default List<Long> applyExpiration(byte[] key, org.springframework.data.redis.core.types.Expiration expiration,
265288
FieldExpirationOptions options, byte[]... fields) {
@@ -304,9 +327,8 @@ default List<Long> applyExpiration(byte[] key, org.springframework.data.redis.co
304327
* @param fields must not be {@literal null}.
305328
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
306329
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
307-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
308-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
309-
* transaction.
330+
* is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no such
331+
* field; {@literal null} when used in pipeline / transaction.
310332
* @see <a href="https://redis.io/docs/latest/commands/hexpire/">Redis Documentation: HEXPIRE</a>
311333
* @since 3.5
312334
*/
@@ -324,9 +346,8 @@ default List<Long> hExpire(byte[] key, long seconds, byte[]... fields) {
324346
* @param fields must not be {@literal null}.
325347
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
326348
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
327-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
328-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
329-
* transaction.
349+
* is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no such
350+
* field; {@literal null} when used in pipeline / transaction.
330351
* @see <a href="https://redis.io/docs/latest/commands/hexpire/">Redis Documentation: HEXPIRE</a>
331352
* @since 3.5
332353
*/
@@ -362,9 +383,8 @@ default List<Long> hExpire(byte[] key, Duration ttl, byte[]... fields) {
362383
* @param fields must not be {@literal null}.
363384
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
364385
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
365-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
366-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
367-
* transaction.
386+
* is set/updated; {@code 0} indicating the expiration time is not set ; {@code -2} indicating there is no
387+
* such field; {@literal null} when used in pipeline / transaction.
368388
* @see <a href="https://redis.io/docs/latest/commands/hpexpire/">Redis Documentation: HPEXPIRE</a>
369389
* @since 3.5
370390
*/
@@ -382,9 +402,8 @@ default List<Long> hpExpire(byte[] key, long millis, byte[]... fields) {
382402
* @param fields must not be {@literal null}.
383403
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
384404
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
385-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
386-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
387-
* transaction.
405+
* is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no such
406+
* field; {@literal null} when used in pipeline / transaction.
388407
* @see <a href="https://redis.io/docs/latest/commands/hpexpire/">Redis Documentation: HPEXPIRE</a>
389408
* @since 3.5
390409
*/
@@ -420,9 +439,8 @@ default List<Long> hpExpire(byte[] key, Duration ttl, byte[]... fields) {
420439
* @param fields must not be {@literal null}.
421440
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
422441
* deleted already due to expiration, or provided expiry interval is in the past; {@code 1} indicating
423-
* expiration time is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX |
424-
* GT | LT condition is not met); {@code -2} indicating there is no such field; {@literal null} when used in
425-
* pipeline / transaction.
442+
* expiration time is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating
443+
* there is no such field; {@literal null} when used in pipeline / transaction.
426444
* @see <a href="https://redis.io/docs/latest/commands/hexpireat/">Redis Documentation: HEXPIREAT</a>
427445
* @since 3.5
428446
*/
@@ -457,9 +475,8 @@ default List<Long> hExpireAt(byte[] key, long unixTime, byte[]... fields) {
457475
* @param fields must not be {@literal null}.
458476
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
459477
* deleted already due to expiration, or provided expiry interval is in the past; {@code 1} indicating
460-
* expiration time is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX |
461-
* GT | LT condition is not met); {@code -2} indicating there is no such field; {@literal null} when used in
462-
* pipeline / transaction.
478+
* expiration time is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating
479+
* there is no such field; {@literal null} when used in pipeline / transaction.
463480
* @see <a href="https://redis.io/docs/latest/commands/hpexpireat/">Redis Documentation: HPEXPIREAT</a>
464481
* @since 3.5
465482
*/
@@ -531,8 +548,6 @@ List<Long> hpExpireAt(byte[] key, long unixTimeInMillis, FieldExpirationOptions.
531548
* @since 3.5
532549
*/
533550
@Nullable
534-
// TODO: this is complete nonsense as it would jeopardize negative values
535-
// TODO: this should be a List<Map.Entry<byte, Expiration>>
536551
List<Long> hTtl(byte[] key, TimeUnit timeUnit, byte[]... fields);
537552

538553
/**

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

+8-12
Original file line numberDiff line numberDiff line change
@@ -2341,9 +2341,8 @@ Long zRangeStoreRevByScore(String dstKey, String srcKey,
23412341
* @param fields must not be {@literal null}.
23422342
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
23432343
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
2344-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
2345-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
2346-
* transaction.
2344+
* is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no such
2345+
* field; {@literal null} when used in pipeline / transaction.
23472346
* @see <a href="https://redis.io/docs/latest/commands/hexpire/">Redis Documentation: HEXPIRE</a>
23482347
* @since 3.5
23492348
*/
@@ -2377,9 +2376,8 @@ default List<Long> hExpire(String key, long seconds, String... fields) {
23772376
* @param fields must not be {@literal null}.
23782377
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
23792378
* deleted already due to expiration, or provided expiry interval is 0; {@code 1} indicating expiration time
2380-
* is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX | GT | LT condition
2381-
* is not met); {@code -2} indicating there is no such field; {@literal null} when used in pipeline /
2382-
* transaction.
2379+
* is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating there is no such
2380+
* field; {@literal null} when used in pipeline / transaction.
23832381
* @see <a href="https://redis.io/docs/latest/commands/hpexpire/">Redis Documentation: HPEXPIRE</a>
23842382
* @since 3.5
23852383
*/
@@ -2413,9 +2411,8 @@ default List<Long> hpExpire(String key, long millis, String... fields) {
24132411
* @param fields must not be {@literal null}.
24142412
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
24152413
* deleted already due to expiration, or provided expiry interval is in the past; {@code 1} indicating
2416-
* expiration time is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX |
2417-
* GT | LT condition is not met); {@code -2} indicating there is no such field; {@literal null} when used in
2418-
* pipeline / transaction.
2414+
* expiration time is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating
2415+
* there is no such field; {@literal null} when used in pipeline / transaction.
24192416
* @see <a href="https://redis.io/docs/latest/commands/hexpireat/">Redis Documentation: HEXPIREAT</a>
24202417
* @since 3.5
24212418
*/
@@ -2449,9 +2446,8 @@ default List<Long> hExpireAt(String key, long unixTime, String... fields) {
24492446
* @param fields must not be {@literal null}.
24502447
* @return a list of {@link Long} values for each of the fields provided: {@code 2} indicating the specific field is
24512448
* deleted already due to expiration, or provided expiry interval is in the past; {@code 1} indicating
2452-
* expiration time is set/updated; {@code 0} indicating the expiration time is not set (a provided NX | XX |
2453-
* GT | LT condition is not met); {@code -2} indicating there is no such field; {@literal null} when used in
2454-
* pipeline / transaction.
2449+
* expiration time is set/updated; {@code 0} indicating the expiration time is not set; {@code -2} indicating
2450+
* there is no such field; {@literal null} when used in pipeline / transaction.
24552451
* @see <a href="https://redis.io/docs/latest/commands/hpexpireat/">Redis Documentation: HPEXPIREAT</a>
24562452
* @since 3.5
24572453
*/

0 commit comments

Comments
 (0)