Skip to content

Commit

Permalink
DATAREDIS-1031 - Fix reactive pExpire/pExpireAt to invoke correct com…
Browse files Browse the repository at this point in the history
…mand.

We now invoke the correct PEXPIRE(AT) command. Previously, we invoked EXPIRE/EXPIREAT commands resulting in the wrong command being called.

Original Pull Request: #474
  • Loading branch information
mp911de authored and christophstrobl committed Sep 4, 2019
1 parent 1c48021 commit 1ae1acf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ default Mono<List<ByteBuffer>> keys(ByteBuffer pattern) {
* Find all keys matching the given {@literal pattern}.<br />
* 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 <a href="https://redis.io/commands/keys">Redis Documentation: KEYS</a>
Expand Down Expand Up @@ -462,7 +462,7 @@ default Mono<Boolean> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public Flux<BooleanResponse<ExpireCommand>> pExpire(Publisher<ExpireCommand> 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));
}));
}
Expand Down Expand Up @@ -294,7 +294,7 @@ public Flux<BooleanResponse<ExpireAtCommand>> pExpireAt(Publisher<ExpireAtComman
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getExpireAt(), "Expire at must not be null!");

return cmd.expireat(command.getKey(), command.getExpireAt().toEpochMilli())
return cmd.pexpireat(command.getKey(), command.getExpireAt().toEpochMilli())
.map(value -> new BooleanResponse<>(command, value));
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 1ae1acf

Please sign in to comment.