From c19a0a669348670e05e042c831ce993bc8ed326c Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 2 Sep 2019 15:32:43 +0200 Subject: [PATCH 1/2] DATAREDIS-1031 - Prepare issue branch. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6e446970fc..6b1af3544d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-redis - 2.2.0.BUILD-SNAPSHOT + 2.2.0.DATAREDIS-1031-SNAPSHOT Spring Data Redis From 11d5aff4688f825965173344f24696a60a4ed89d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 2 Sep 2019 15:50:59 +0200 Subject: [PATCH 2/2] 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. --- .../data/redis/connection/ReactiveKeyCommands.java | 4 ++-- .../lettuce/LettuceReactiveKeyCommands.java | 4 ++-- .../lettuce/LettuceReactiveKeyCommandsTests.java | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java index 6dc48b20a6..0d81a533fb 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java @@ -131,7 +131,7 @@ default Mono> keys(ByteBuffer pattern) { * Find all keys matching the given {@literal pattern}.
* It is recommended to use {@link #scan(ScanOptions)} to iterate over the keyspace as {@link #keys(Publisher)} is a * non-interruptible and expensive Redis operation. - * + * * @param patterns must not be {@literal null}. * @return * @see Redis Documentation: KEYS @@ -462,7 +462,7 @@ default Mono pExpire(ByteBuffer key, Duration timeout) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(timeout, "Timeout must not be null!"); - return expire(Mono.just(new ExpireCommand(key, timeout))).next().map(BooleanResponse::getOutput); + return pExpire(Mono.just(new ExpireCommand(key, timeout))).next().map(BooleanResponse::getOutput); } /** diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommands.java index 3b811b0dc6..d6b9ca1b06 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommands.java @@ -262,7 +262,7 @@ public Flux> pExpire(Publisher com Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getTimeout(), "Timeout must not be null!"); - return cmd.pexpire(command.getKey(), command.getTimeout().getSeconds()) + return cmd.pexpire(command.getKey(), command.getTimeout().toMillis()) .map(value -> new BooleanResponse<>(command, value)); })); } @@ -294,7 +294,7 @@ public Flux> pExpireAt(Publisher new BooleanResponse<>(command, value)); })); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsTests.java index 4955284292..bef4435dfc 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsTests.java @@ -278,7 +278,7 @@ public void shouldExpireKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); } - @Test // DATAREDIS-602 + @Test // DATAREDIS-602, DATAREDIS-1031 public void shouldPreciseExpireKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -288,10 +288,10 @@ public void shouldPreciseExpireKeysCorrectly() { .expectComplete() // .verify(); - assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); + assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } - @Test // DATAREDIS-602 + @Test // DATAREDIS-602, DATAREDIS-1031 public void shouldExpireAtKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -302,10 +302,10 @@ public void shouldExpireAtKeysCorrectly() { .expectComplete() // .verify(); - assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); + assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } - @Test // DATAREDIS-602 + @Test // DATAREDIS-602, DATAREDIS-1031 public void shouldPreciseExpireAtKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -316,7 +316,7 @@ public void shouldPreciseExpireAtKeysCorrectly() { .expectComplete() // .verify(); - assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); + assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } @Test // DATAREDIS-602