Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CLIENT NO-EVICT command #1989

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ public RedisFuture<String> clientList() {
return dispatch(commandBuilder.clientList());
}

@Override
public RedisFuture<String> clientNoEvict(boolean on) {
return dispatch(commandBuilder.clientNoEvict(on));
}

@Override
public RedisFuture<Long> clientId() {
return dispatch(commandBuilder.clientId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ public Mono<String> clientList() {
return createMono(commandBuilder::clientList);
}

@Override
public Mono<String> clientNoEvict(boolean on) {
return createMono(() -> commandBuilder.clientNoEvict(on));
}

@Override
public Mono<Long> clientId() {
return createMono(commandBuilder::clientId);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ Command<K, V, String> clientList() {
return createCommand(CLIENT, new StatusOutput<>(codec), args);
}

Command<K, V, String> clientNoEvict(boolean on) {
CommandArgs<K, V> args = new CommandArgs<>(codec).add("NO-EVICT").add(on ? ON : OFF);
return createCommand(CLIENT, new StatusOutput<>(codec), args);
}

Command<K, V, Long> clientId() {
CommandArgs<K, V> args = new CommandArgs<>(codec).add(ID);
return createCommand(CLIENT, new IntegerOutput<>(codec), args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public interface RedisServerAsyncCommands<K, V> {
*/
RedisFuture<String> clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
RedisFuture<String> clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public interface RedisServerReactiveCommands<K, V> {
*/
Mono<String> clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
Mono<String> clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public interface RedisServerCommands<K, V> {
*/
String clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
String clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public interface NodeSelectionServerAsyncCommands<K, V> {
*/
AsyncExecutions<String> clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
AsyncExecutions<String> clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -107,6 +107,15 @@ public interface NodeSelectionServerCommands<K, V> {
*/
Executions<String> clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
Executions<String> clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ interface RedisServerCoroutinesCommands<K : Any, V : Any> {
*/
suspend fun clientList(): String?

/**
* Sets the client eviction mode for the current connection.
*
* @param on @code true} will turn eviction mode on, and `false` will turn it off.
* @return String simple-string-reply `OK`.
* @since 7.0
*/
suspend fun clientNoEvict(on: Boolean): String?

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ internal class RedisServerCoroutinesCommandsImpl<K : Any, V : Any>(internal val

override suspend fun clientList(): String? = ops.clientList().awaitFirstOrNull()

override suspend fun clientNoEvict(on: Boolean): String? = ops.clientNoEvict(on).awaitFirstOrNull()

override suspend fun clientPause(timeout: Long): String? = ops.clientPause(timeout).awaitFirstOrNull()

override suspend fun clientSetname(name: K): String? = ops.clientSetname(name).awaitFirstOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ public interface RedisServerCommands<K, V> {
*/
String clientList();

/**
* Sets the client eviction mode for the current connection.
*
* @param on {@code true} will turn eviction mode on, and {@code false} will turn it off.
* @return String simple-string-reply {@code OK}.
* @since 7.0
*/
String clientNoEvict(boolean on);

/**
* Stop processing commands from clients for some time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ void clientList() {
assertThat(redis.clientList().contains("addr=")).isTrue();
}

@Test
@EnabledOnCommand("EVAL_RO") // Redis 7.0
void clientNoEvict() {
assertThat(redis.clientNoEvict(true)).isEqualTo("OK");
assertThat(redis.clientNoEvict(false)).isEqualTo("OK");
}

@Test
@EnabledOnCommand("ACL")
void clientTracking() {
Expand Down