Skip to content

Commit

Permalink
address review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dengliming committed May 3, 2024
1 parent cc5bb8b commit bf9cc1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/KillArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static KillArgs user(String username) {
*
* @return new {@link KillArgs} with {@literal MAXAGE} set.
* @see KillArgs#maxAge(Long)
* @since 6.3
* @since 7.0
*/
public static KillArgs maxAge(Long maxAge) {
return new KillArgs().maxAge(maxAge);
Expand Down Expand Up @@ -258,7 +258,7 @@ public KillArgs type(Type type) {
*
* @param maxAge must not be {@code null}.
* @return {@code this} {@link KillArgs}.
* @since 6.3
* @since 7.0
*/
public KillArgs maxAge(Long maxAge) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,20 @@ void clientKillUser() {

@Test
void clientKillMaxAge() throws InterruptedException {
RedisCommands<String, String> connection2 = client.connect().sync();
// can not find other new command to use `@EnabledOnCommand` for now, so check the version
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("8.0"));

RedisCommands<String, String> connection2 = client.connect().sync();
long inactiveId = connection2.clientId();
long maxAge = 2L;
// sleep for maxAge * 2 seconds, to be sure
TimeUnit.SECONDS.sleep(maxAge * 2);
RedisCommands<String, String> connection3 = client.connect().sync();
long activeId = connection3.clientId();
assertThat(redis.clientKill(KillArgs.Builder.maxAge(maxAge))).isGreaterThan(0);

assertThat(redis.clientList(ClientListArgs.Builder.ids(inactiveId))).isBlank();
assertThat(redis.clientList(ClientListArgs.Builder.ids(activeId))).isNotBlank();
}

@Test
Expand Down

0 comments on commit bf9cc1b

Please sign in to comment.