diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index 433132e54c..b8380547e3 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -4155,6 +4155,13 @@ public String clientPause(final long timeout, final ClientPauseMode mode) { return connection.getBulkReply(); } + @Override + public String clientNoEvict(boolean on) { + checkIsInMultiOrPipeline(); + connection.sendCommand(CLIENT, (NO+"-"+EVICT).getBytes(), on ? ON.getRaw() : OFF.getRaw()); + return connection.getBulkReply(); + } + public List time() { checkIsInMultiOrPipeline(); connection.sendCommand(Command.TIME); diff --git a/src/main/java/redis/clients/jedis/Protocol.java b/src/main/java/redis/clients/jedis/Protocol.java index 14fd1617a9..82823816ec 100644 --- a/src/main/java/redis/clients/jedis/Protocol.java +++ b/src/main/java/redis/clients/jedis/Protocol.java @@ -260,7 +260,7 @@ public static enum Keyword implements Rawable { CAT, GENPASS, LOG, INCR, SAVE, JUSTID, WITHVALUES, UNBLOCK, NOMKSTREAM, MINID, DB, ABSTTL, TO, TIMEOUT, ABORT, NX, XX, EX, PX, EXAT, PXAT, CH, WITHCOORD, WITHDIST, WITHHASH, STOREDIST, COPY, KEEPTTL, AUTH, AUTH2, INFO, CHANNELS, NUMPAT, NUMSUB, LCS, KEYS, STRINGS, FULL, NOW, VERSION, - ANY, FROMMEMBER, FROMLONLAT, BYRADIUS, BYBOX, BYLEX, BYSCORE, REV; + ANY, FROMMEMBER, FROMLONLAT, BYRADIUS, BYBOX, BYLEX, BYSCORE, REV, EVICT, ON, OFF; private final byte[] raw; diff --git a/src/main/java/redis/clients/jedis/commands/ClientBinaryCommands.java b/src/main/java/redis/clients/jedis/commands/ClientBinaryCommands.java index d3963e4c0b..3951485f03 100644 --- a/src/main/java/redis/clients/jedis/commands/ClientBinaryCommands.java +++ b/src/main/java/redis/clients/jedis/commands/ClientBinaryCommands.java @@ -133,4 +133,12 @@ public interface ClientBinaryCommands { */ String clientPause(long timeout, ClientPauseMode mode); + /** + * Set 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 OK + */ + String clientNoEvict(boolean on); + } diff --git a/src/main/java/redis/clients/jedis/commands/ClientCommands.java b/src/main/java/redis/clients/jedis/commands/ClientCommands.java index e75d3d0acd..be2870ece5 100644 --- a/src/main/java/redis/clients/jedis/commands/ClientCommands.java +++ b/src/main/java/redis/clients/jedis/commands/ClientCommands.java @@ -96,9 +96,7 @@ public interface ClientCommands { * blocking operation, such as for instance BRPOP or XREAD or WAIT. * * @param clientId The id of the client - * @return Specifically: - * 1 if the client was unblocked successfully. - * 0 if the client wasn't unblocked. + * @return 1 if the client was unblocked successfully, 0 if the client wasn't unblocked. */ long clientUnblock(long clientId); @@ -108,9 +106,7 @@ public interface ClientCommands { * * @param clientId The id of the client * @param unblockType TIMEOUT|ERROR - * @return Specifically: - * 1 if the client was unblocked successfully. - * 0 if the client wasn't unblocked. + * @return 1 if the client was unblocked successfully, 0 if the client wasn't unblocked. */ long clientUnblock(long clientId, UnblockType unblockType); @@ -133,4 +129,12 @@ public interface ClientCommands { */ String clientPause(long timeout, ClientPauseMode mode); + /** + * Set 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 OK + */ + String clientNoEvict(boolean on); + } diff --git a/src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java b/src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java index 411fa6a331..e6c3c028bb 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java @@ -325,6 +325,12 @@ public Long call() throws Exception { } } + @Test + public void clientNoEvict() { + assertEquals("OK", jedis.clientNoEvict(true)); + assertEquals("OK", jedis.clientNoEvict(false)); + } + @Test public void memoryDoctorString() { String memoryInfo = jedis.memoryDoctor();