Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 621164d

Browse files
committedSep 2, 2019
DATAREDIS-1031 - Fix reactive pExpire/pExpireAt to invoke correct command.
We now invoke the correct PEXPIRE(AT) command. Previously, we invoked EXPIRE/EXPIREAT commands resulting in the wrong command being called.
1 parent c19a0a6 commit 621164d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed
 

‎src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ default Mono<List<ByteBuffer>> keys(ByteBuffer pattern) {
131131
* Find all keys matching the given {@literal pattern}.<br />
132132
* It is recommended to use {@link #scan(ScanOptions)} to iterate over the keyspace as {@link #keys(Publisher)} is a
133133
* non-interruptible and expensive Redis operation.
134-
*
134+
*
135135
* @param patterns must not be {@literal null}.
136136
* @return
137137
* @see <a href="https://redis.io/commands/keys">Redis Documentation: KEYS</a>
@@ -462,7 +462,7 @@ default Mono<Boolean> pExpire(ByteBuffer key, Duration timeout) {
462462
Assert.notNull(key, "Key must not be null!");
463463
Assert.notNull(timeout, "Timeout must not be null!");
464464

465-
return expire(Mono.just(new ExpireCommand(key, timeout))).next().map(BooleanResponse::getOutput);
465+
return pExpire(Mono.just(new ExpireCommand(key, timeout))).next().map(BooleanResponse::getOutput);
466466
}
467467

468468
/**

‎src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommands.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public Flux<BooleanResponse<ExpireAtCommand>> pExpireAt(Publisher<ExpireAtComman
294294
Assert.notNull(command.getKey(), "Key must not be null!");
295295
Assert.notNull(command.getExpireAt(), "Expire at must not be null!");
296296

297-
return cmd.expireat(command.getKey(), command.getExpireAt().toEpochMilli())
297+
return cmd.pexpireat(command.getKey(), command.getExpireAt().toEpochMilli())
298298
.map(value -> new BooleanResponse<>(command, value));
299299
}));
300300
}

‎src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public void shouldExpireKeysCorrectly() {
278278
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L);
279279
}
280280

281-
@Test // DATAREDIS-602
281+
@Test // DATAREDIS-602, DATAREDIS-1031
282282
public void shouldPreciseExpireKeysCorrectly() {
283283

284284
nativeCommands.set(KEY_1, VALUE_1);
@@ -288,10 +288,10 @@ public void shouldPreciseExpireKeysCorrectly() {
288288
.expectComplete() //
289289
.verify();
290290

291-
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L);
291+
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11);
292292
}
293293

294-
@Test // DATAREDIS-602
294+
@Test // DATAREDIS-602, DATAREDIS-1031
295295
public void shouldExpireAtKeysCorrectly() {
296296

297297
nativeCommands.set(KEY_1, VALUE_1);
@@ -302,10 +302,10 @@ public void shouldExpireAtKeysCorrectly() {
302302
.expectComplete() //
303303
.verify();
304304

305-
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L);
305+
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11);
306306
}
307307

308-
@Test // DATAREDIS-602
308+
@Test // DATAREDIS-602, DATAREDIS-1031
309309
public void shouldPreciseExpireAtKeysCorrectly() {
310310

311311
nativeCommands.set(KEY_1, VALUE_1);
@@ -316,7 +316,7 @@ public void shouldPreciseExpireAtKeysCorrectly() {
316316
.expectComplete() //
317317
.verify();
318318

319-
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L);
319+
assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11);
320320
}
321321

322322
@Test // DATAREDIS-602

0 commit comments

Comments
 (0)
Please sign in to comment.