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.

Original Pull Request: #474
This commit is contained in:
Mark Paluch
2019-09-02 15:50:59 +02:00
committed by Christoph Strobl
parent 1ec61c5e43
commit 8c8ba7a796
3 changed files with 10 additions and 7 deletions

View File

@@ -131,7 +131,7 @@ public interface ReactiveKeyCommands {
* 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>
@@ -462,7 +462,7 @@ public interface ReactiveKeyCommands {
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);
}
/**

View File

@@ -262,7 +262,7 @@ class LettuceReactiveKeyCommands implements ReactiveKeyCommands {
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 @@ class LettuceReactiveKeyCommands implements ReactiveKeyCommands {
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));
}));
}

View File

@@ -278,7 +278,7 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
assertThat(nativeCommands.ttl(KEY_1), is(greaterThan(8L)));
}
@Test // DATAREDIS-602
@Test // DATAREDIS-602, DATAREDIS-1031
public void shouldPreciseExpireKeysCorrectly() {
nativeCommands.set(KEY_1, VALUE_1);
@@ -289,9 +289,10 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
.verify();
assertThat(nativeCommands.ttl(KEY_1), is(greaterThan(8L)));
assertThat(nativeCommands.ttl(KEY_1), is(lessThan(11L)));
}
@Test // DATAREDIS-602
@Test // DATAREDIS-602, DATAREDIS-1031
public void shouldExpireAtKeysCorrectly() {
nativeCommands.set(KEY_1, VALUE_1);
@@ -303,9 +304,10 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
.verify();
assertThat(nativeCommands.ttl(KEY_1), is(greaterThan(8L)));
assertThat(nativeCommands.ttl(KEY_1), is(lessThan(11L)));
}
@Test // DATAREDIS-602
@Test // DATAREDIS-602, DATAREDIS-1031
public void shouldPreciseExpireAtKeysCorrectly() {
nativeCommands.set(KEY_1, VALUE_1);
@@ -317,6 +319,7 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
.verify();
assertThat(nativeCommands.ttl(KEY_1), is(greaterThan(8L)));
assertThat(nativeCommands.ttl(KEY_1), is(lessThan(11L)));
}
@Test // DATAREDIS-602