From 5dd0edb119214ca6636880b14f6b79bd530bead9 Mon Sep 17 00:00:00 2001 From: anshlykov Date: Thu, 15 Oct 2020 16:47:30 +0300 Subject: [PATCH 1/3] Add GET parameter to SET command --- src/main/java/io/lettuce/core/SetArgs.java | 29 +++++++++++++++++++ .../StringCommandIntegrationTests.java | 8 +++++ 2 files changed, 37 insertions(+) diff --git a/src/main/java/io/lettuce/core/SetArgs.java b/src/main/java/io/lettuce/core/SetArgs.java index 602e06775b..643eac990e 100644 --- a/src/main/java/io/lettuce/core/SetArgs.java +++ b/src/main/java/io/lettuce/core/SetArgs.java @@ -26,6 +26,7 @@ * @author Will Glozer * @author Vincent Rischmann * @author Mark Paluch + * @author Andrey Shlykov */ public class SetArgs implements CompositeArgument { @@ -39,6 +40,8 @@ public class SetArgs implements CompositeArgument { private boolean keepttl = false; + private boolean get = false; + /** * Builder entry points for {@link SetArgs}. */ @@ -103,6 +106,17 @@ public static SetArgs keepttl() { return new SetArgs().keepttl(); } + /** + * Creates new {@link SetArgs} and enabling {@literal GET}. + * + * @return new {@link SetArgs} with {@literal GET} enabled. + * @see SetArgs#get() + * @since 6.1 + */ + public static SetArgs get() { + return new SetArgs().get(); + } + } /** @@ -163,6 +177,17 @@ public SetArgs xx() { return this; } + /** + * Return the old value stored at key, or nil when key did not exist. + * + * @return {@code this} {@link SetArgs}. + */ + public SetArgs get() { + + this.get = true; + return this; + } + public void build(CommandArgs args) { if (ex != null) { @@ -184,6 +209,10 @@ public void build(CommandArgs args) { if (keepttl) { args.add("KEEPTTL"); } + + if (get) { + args.add("GET"); + } } } diff --git a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java index 576172af98..e51879bcac 100644 --- a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java @@ -43,6 +43,7 @@ * @author Will Glozer * @author Mark Paluch * @author dengliming + * @author Andrey Shlykov */ @ExtendWith(LettuceExtension.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -191,6 +192,13 @@ void setNegativePX() { assertThatThrownBy(() -> redis.set(key, value, px(-1000))).isInstanceOf(RedisException. class); } + @Test + void setGet() { + assertThat(redis.set(key, value, SetArgs.Builder.get())).isNull(); + assertThat(redis.set(key, "value2", SetArgs.Builder.get())).isEqualTo(value); + assertThat(redis.get(key)).isEqualTo("value2"); + } + @Test void setbit() { assertThat(redis.setbit(key, 0, 1)).isEqualTo(0); From f1bc7ead5986fa0f70eb9e35bf997ee4bd3dd035 Mon Sep 17 00:00:00 2001 From: anshlykov Date: Mon, 16 Nov 2020 18:13:39 +0300 Subject: [PATCH 2/3] setget command --- .../core/AbstractRedisAsyncCommands.java | 10 ++++++++ .../core/AbstractRedisReactiveCommands.java | 10 ++++++++ .../io/lettuce/core/RedisCommandBuilder.java | 12 ++++++++++ .../api/async/RedisStringAsyncCommands.java | 23 +++++++++++++++++++ .../reactive/RedisStringReactiveCommands.java | 23 +++++++++++++++++++ .../core/api/sync/RedisStringCommands.java | 23 +++++++++++++++++++ .../NodeSelectionStringAsyncCommands.java | 23 +++++++++++++++++++ .../api/sync/NodeSelectionStringCommands.java | 23 +++++++++++++++++++ .../RedisStringCoroutinesCommands.kt | 23 ++++++++++++++++++- .../RedisStringCoroutinesCommandsImpl.kt | 4 ++++ .../lettuce/core/api/RedisStringCommands.java | 23 +++++++++++++++++++ .../StringCommandIntegrationTests.java | 7 +++--- 12 files changed, 200 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index ab55044d2b..5200327c76 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -726,6 +726,16 @@ public RedisFuture getset(K key, V value) { return dispatch(commandBuilder.getset(key, value)); } + @Override + public RedisFuture setget(K key, V value) { + return dispatch(commandBuilder.setget(key, value)); + } + + @Override + public RedisFuture setget(K key, V value, SetArgs setArgs) { + return dispatch(commandBuilder.setget(key, value, setArgs)); + } + @Override public RedisFuture hdel(K key, K... fields) { return dispatch(commandBuilder.hdel(key, fields)); diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index d5a82a1d63..8711c46f52 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -787,6 +787,16 @@ public Mono getset(K key, V value) { return createMono(() -> commandBuilder.getset(key, value)); } + @Override + public Mono setget(K key, V value) { + return createMono(() -> commandBuilder.setget(key, value)); + } + + @Override + public Mono setget(K key, V value, SetArgs setArgs) { + return createMono(() -> commandBuilder.setget(key, value, setArgs)); + } + @Override public Mono hdel(K key, K... fields) { return createMono(() -> commandBuilder.hdel(key, fields)); diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index d10cc60cb7..2e02c43d43 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -1832,6 +1832,18 @@ Command set(K key, V value, SetArgs setArgs) { return createCommand(SET, new StatusOutput<>(codec), args); } + Command setget(K key, V value) { + return setget(key, value, new SetArgs()); + } + + Command setget(K key, V value, SetArgs setArgs) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(value); + setArgs.get().build(args); + return createCommand(SET, new ValueOutput<>(codec), args); + } + Command setbit(K key, long offset, int value) { notNullKey(key); diff --git a/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java index 3eaa62436d..f7c01d17ef 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java @@ -306,6 +306,29 @@ public interface RedisStringAsyncCommands { */ RedisFuture set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + RedisFuture setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + RedisFuture setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java index 8e85c2d1a5..4dafc235d5 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java @@ -309,6 +309,29 @@ public interface RedisStringReactiveCommands { */ Mono set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + Mono setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + Mono setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java index cd4d1c6567..c4fa064522 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java @@ -306,6 +306,29 @@ public interface RedisStringCommands { */ String set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + V setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + V setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java index 88df7e809c..a94259b855 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java @@ -306,6 +306,29 @@ public interface NodeSelectionStringAsyncCommands { */ AsyncExecutions set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + AsyncExecutions setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + AsyncExecutions setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java index a4f6bd4880..fda84c074d 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java @@ -306,6 +306,29 @@ public interface NodeSelectionStringCommands { */ Executions set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + Executions setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + Executions setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt index 8e8a3f4dd8..7ef82e7d9b 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt @@ -257,7 +257,7 @@ interface RedisStringCoroutinesCommands { * @param keys the key. * @return List array-reply list of values at the specified keys. */ - fun mget(vararg keys: K): Flow> + fun mget(vararg keys: K): Flow> /** * Set multiple keys to multiple values. @@ -296,6 +296,27 @@ interface RedisStringCoroutinesCommands { */ suspend fun set(key: K, value: V, setArgs: SetArgs): String? + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @return V bulk-string-reply the old value stored at `key`, or `null` when `key` did not exist. + * @since 6.2 + */ + suspend fun setget(key: K, value: V): V? + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * @return V bulk-string-reply the old value stored at `key`, or `null` when `key` did not exist. + * @since 6.2 + */ + suspend fun setget(key: K, value: V, setArgs: SetArgs): V? + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt index b15f31bde1..098728d6cf 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt @@ -85,6 +85,10 @@ internal class RedisStringCoroutinesCommandsImpl(internal val override suspend fun set(key: K, value: V, setArgs: SetArgs): String? = ops.set(key, value, setArgs).awaitFirstOrNull() + override suspend fun setget(key: K, value: V): V? = ops.setget(key, value).awaitFirstOrNull() + + override suspend fun setget(key: K, value: V, setArgs: SetArgs): V? = ops.setget(key, value, setArgs).awaitFirstOrNull() + override suspend fun setbit(key: K, offset: Long, value: Int): Long? = ops.setbit(key, offset, value).awaitFirstOrNull() override suspend fun setex(key: K, seconds: Long, value: V): String? = ops.setex(key, seconds, value).awaitFirstOrNull() diff --git a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java index 45955e777c..d04aa4307f 100644 --- a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java @@ -305,6 +305,29 @@ public interface RedisStringCommands { */ String set(K key, V value, SetArgs setArgs); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + V setget(K key, V value); + + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value + * @param setArgs the command arguments + * + * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. + * @since 6.2 + */ + V setget(K key, V value, SetArgs setArgs); + /** * Sets or clears the bit at offset in the string value stored at key. * diff --git a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java index e51879bcac..c74ed435a9 100644 --- a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java @@ -193,9 +193,10 @@ void setNegativePX() { } @Test - void setGet() { - assertThat(redis.set(key, value, SetArgs.Builder.get())).isNull(); - assertThat(redis.set(key, "value2", SetArgs.Builder.get())).isEqualTo(value); + @EnabledOnCommand("ZMSCORE") // Redis 6.2 + void setget() { + assertThat(redis.setget(key, value)).isNull(); + assertThat(redis.setget(key, "value2")).isEqualTo(value); assertThat(redis.get(key)).isEqualTo("value2"); } From cb4972f695f200ca2d4cd379a99860e492443d8a Mon Sep 17 00:00:00 2001 From: anshlykov Date: Tue, 8 Dec 2020 16:26:07 +0300 Subject: [PATCH 3/3] rename setget to setGet --- .../core/AbstractRedisAsyncCommands.java | 8 ++--- .../core/AbstractRedisReactiveCommands.java | 8 ++--- .../io/lettuce/core/RedisCommandBuilder.java | 10 ++++--- src/main/java/io/lettuce/core/SetArgs.java | 29 ------------------- .../api/async/RedisStringAsyncCommands.java | 4 +-- .../reactive/RedisStringReactiveCommands.java | 4 +-- .../core/api/sync/RedisStringCommands.java | 4 +-- .../NodeSelectionStringAsyncCommands.java | 4 +-- .../api/sync/NodeSelectionStringCommands.java | 4 +-- .../RedisStringCoroutinesCommands.kt | 6 ++-- .../RedisStringCoroutinesCommandsImpl.kt | 4 +-- .../lettuce/core/api/RedisStringCommands.java | 4 +-- .../StringCommandIntegrationTests.java | 6 ++-- 13 files changed, 34 insertions(+), 61 deletions(-) diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index 5200327c76..68147ed41a 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -727,13 +727,13 @@ public RedisFuture getset(K key, V value) { } @Override - public RedisFuture setget(K key, V value) { - return dispatch(commandBuilder.setget(key, value)); + public RedisFuture setGet(K key, V value) { + return dispatch(commandBuilder.setGet(key, value)); } @Override - public RedisFuture setget(K key, V value, SetArgs setArgs) { - return dispatch(commandBuilder.setget(key, value, setArgs)); + public RedisFuture setGet(K key, V value, SetArgs setArgs) { + return dispatch(commandBuilder.setGet(key, value, setArgs)); } @Override diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index 8711c46f52..1aaaa08d27 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -788,13 +788,13 @@ public Mono getset(K key, V value) { } @Override - public Mono setget(K key, V value) { - return createMono(() -> commandBuilder.setget(key, value)); + public Mono setGet(K key, V value) { + return createMono(() -> commandBuilder.setGet(key, value)); } @Override - public Mono setget(K key, V value, SetArgs setArgs) { - return createMono(() -> commandBuilder.setget(key, value, setArgs)); + public Mono setGet(K key, V value, SetArgs setArgs) { + return createMono(() -> commandBuilder.setGet(key, value, setArgs)); } @Override diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index 2e02c43d43..68bfb2567a 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -1832,15 +1832,17 @@ Command set(K key, V value, SetArgs setArgs) { return createCommand(SET, new StatusOutput<>(codec), args); } - Command setget(K key, V value) { - return setget(key, value, new SetArgs()); + Command setGet(K key, V value) { + return setGet(key, value, new SetArgs()); } - Command setget(K key, V value, SetArgs setArgs) { + Command setGet(K key, V value, SetArgs setArgs) { notNullKey(key); CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(value); - setArgs.get().build(args); + setArgs.build(args); + args.add("GET"); + return createCommand(SET, new ValueOutput<>(codec), args); } diff --git a/src/main/java/io/lettuce/core/SetArgs.java b/src/main/java/io/lettuce/core/SetArgs.java index 643eac990e..602e06775b 100644 --- a/src/main/java/io/lettuce/core/SetArgs.java +++ b/src/main/java/io/lettuce/core/SetArgs.java @@ -26,7 +26,6 @@ * @author Will Glozer * @author Vincent Rischmann * @author Mark Paluch - * @author Andrey Shlykov */ public class SetArgs implements CompositeArgument { @@ -40,8 +39,6 @@ public class SetArgs implements CompositeArgument { private boolean keepttl = false; - private boolean get = false; - /** * Builder entry points for {@link SetArgs}. */ @@ -106,17 +103,6 @@ public static SetArgs keepttl() { return new SetArgs().keepttl(); } - /** - * Creates new {@link SetArgs} and enabling {@literal GET}. - * - * @return new {@link SetArgs} with {@literal GET} enabled. - * @see SetArgs#get() - * @since 6.1 - */ - public static SetArgs get() { - return new SetArgs().get(); - } - } /** @@ -177,17 +163,6 @@ public SetArgs xx() { return this; } - /** - * Return the old value stored at key, or nil when key did not exist. - * - * @return {@code this} {@link SetArgs}. - */ - public SetArgs get() { - - this.get = true; - return this; - } - public void build(CommandArgs args) { if (ex != null) { @@ -209,10 +184,6 @@ public void build(CommandArgs args) { if (keepttl) { args.add("KEEPTTL"); } - - if (get) { - args.add("GET"); - } } } diff --git a/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java index f7c01d17ef..e255b2363b 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java @@ -315,7 +315,7 @@ public interface RedisStringAsyncCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - RedisFuture setget(K key, V value); + RedisFuture setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -327,7 +327,7 @@ public interface RedisStringAsyncCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - RedisFuture setget(K key, V value, SetArgs setArgs); + RedisFuture setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java index 4dafc235d5..6c586a22c0 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java @@ -318,7 +318,7 @@ public interface RedisStringReactiveCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - Mono setget(K key, V value); + Mono setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -330,7 +330,7 @@ public interface RedisStringReactiveCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - Mono setget(K key, V value, SetArgs setArgs); + Mono setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java index c4fa064522..d60dcc3514 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java @@ -315,7 +315,7 @@ public interface RedisStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - V setget(K key, V value); + V setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -327,7 +327,7 @@ public interface RedisStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - V setget(K key, V value, SetArgs setArgs); + V setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java index a94259b855..0ac2478a72 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java @@ -315,7 +315,7 @@ public interface NodeSelectionStringAsyncCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - AsyncExecutions setget(K key, V value); + AsyncExecutions setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -327,7 +327,7 @@ public interface NodeSelectionStringAsyncCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - AsyncExecutions setget(K key, V value, SetArgs setArgs); + AsyncExecutions setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java index fda84c074d..8ecdba192a 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java @@ -315,7 +315,7 @@ public interface NodeSelectionStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - Executions setget(K key, V value); + Executions setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -327,7 +327,7 @@ public interface NodeSelectionStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - Executions setget(K key, V value, SetArgs setArgs); + Executions setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt index 7ef82e7d9b..5e0ecc3344 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt @@ -257,7 +257,7 @@ interface RedisStringCoroutinesCommands { * @param keys the key. * @return List array-reply list of values at the specified keys. */ - fun mget(vararg keys: K): Flow> + fun mget(vararg keys: K): Flow> /** * Set multiple keys to multiple values. @@ -304,7 +304,7 @@ interface RedisStringCoroutinesCommands { * @return V bulk-string-reply the old value stored at `key`, or `null` when `key` did not exist. * @since 6.2 */ - suspend fun setget(key: K, value: V): V? + suspend fun setGet(key: K, value: V): V? /** * Set the string value of a key and return its old value. @@ -315,7 +315,7 @@ interface RedisStringCoroutinesCommands { * @return V bulk-string-reply the old value stored at `key`, or `null` when `key` did not exist. * @since 6.2 */ - suspend fun setget(key: K, value: V, setArgs: SetArgs): V? + suspend fun setGet(key: K, value: V, setArgs: SetArgs): V? /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt index 098728d6cf..80ef624b05 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommandsImpl.kt @@ -85,9 +85,9 @@ internal class RedisStringCoroutinesCommandsImpl(internal val override suspend fun set(key: K, value: V, setArgs: SetArgs): String? = ops.set(key, value, setArgs).awaitFirstOrNull() - override suspend fun setget(key: K, value: V): V? = ops.setget(key, value).awaitFirstOrNull() + override suspend fun setGet(key: K, value: V): V? = ops.setGet(key, value).awaitFirstOrNull() - override suspend fun setget(key: K, value: V, setArgs: SetArgs): V? = ops.setget(key, value, setArgs).awaitFirstOrNull() + override suspend fun setGet(key: K, value: V, setArgs: SetArgs): V? = ops.setGet(key, value, setArgs).awaitFirstOrNull() override suspend fun setbit(key: K, offset: Long, value: Int): Long? = ops.setbit(key, offset, value).awaitFirstOrNull() diff --git a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java index d04aa4307f..c7c9e77a74 100644 --- a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java @@ -314,7 +314,7 @@ public interface RedisStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - V setget(K key, V value); + V setGet(K key, V value); /** * Set the string value of a key and return its old value. @@ -326,7 +326,7 @@ public interface RedisStringCommands { * @return V bulk-string-reply the old value stored at {@code key}, or {@code null} when {@code key} did not exist. * @since 6.2 */ - V setget(K key, V value, SetArgs setArgs); + V setGet(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java index c74ed435a9..e0481f634d 100644 --- a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java @@ -194,9 +194,9 @@ void setNegativePX() { @Test @EnabledOnCommand("ZMSCORE") // Redis 6.2 - void setget() { - assertThat(redis.setget(key, value)).isNull(); - assertThat(redis.setget(key, "value2")).isEqualTo(value); + void setGet() { + assertThat(redis.setGet(key, value)).isNull(); + assertThat(redis.setGet(key, "value2")).isEqualTo(value); assertThat(redis.get(key)).isEqualTo("value2"); }