diff --git a/src/main/asciidoc/new-features.adoc b/src/main/asciidoc/new-features.adoc index c2e018073d..aadb5c886c 100644 --- a/src/main/asciidoc/new-features.adoc +++ b/src/main/asciidoc/new-features.adoc @@ -11,6 +11,7 @@ * Configuration of extended Keep-Alive options through `KeepAliveOptions` (only available for some transports/Java versions). * Configuration of netty's `AddressResolverGroup` through `ClientResources`. Uses `DnsAddressResolverGroup` when `netty-resolver-dns` is on the classpath. +* Add support for Redis ACL commands. [[new-features.6-0-0]] == What's new in Lettuce 6.0 diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index 7f8ac08ce2..46834fc260 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -80,12 +80,12 @@ public AbstractRedisAsyncCommands(StatefulConnection connection, RedisCode } @Override - public RedisFuture> aclCat() { + public RedisFuture> aclCat() { return dispatch(commandBuilder.aclCat()); } @Override - public RedisFuture> aclCat(AclCategory category) { + public RedisFuture> aclCat(AclCategory category) { return dispatch(commandBuilder.aclCat(category)); } @@ -105,7 +105,7 @@ public RedisFuture aclGenpass(int bits) { } @Override - public RedisFuture> aclGetuser(String username) { + public RedisFuture> aclGetuser(String username) { return dispatch(commandBuilder.aclGetuser(username)); } diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index 5512711c61..d338e50331 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -22,6 +22,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Supplier; import reactor.core.publisher.Flux; @@ -111,13 +112,13 @@ private EventExecutorGroup getScheduler() { } @Override - public Flux aclCat() { - return createDissolvingFlux(commandBuilder::aclCat); + public Mono> aclCat() { + return createMono(commandBuilder::aclCat); } @Override - public Flux aclCat(AclCategory category) { - return createDissolvingFlux(() -> commandBuilder.aclCat(category)); + public Mono> aclCat(AclCategory category) { + return createMono(() -> commandBuilder.aclCat(category)); } @Override @@ -136,7 +137,7 @@ public Mono aclGenpass(int bits) { } @Override - public Mono> aclGetuser(String username) { + public Mono> aclGetuser(String username) { return createMono(() -> commandBuilder.aclGetuser(username)); } diff --git a/src/main/java/io/lettuce/core/AclCategory.java b/src/main/java/io/lettuce/core/AclCategory.java index a7980ac2b0..db4066d6b3 100644 --- a/src/main/java/io/lettuce/core/AclCategory.java +++ b/src/main/java/io/lettuce/core/AclCategory.java @@ -3,8 +3,8 @@ /** * Enum object describing Redis ACL categories. * - * @since 6.1 * @author Mikhael Sokolov + * @since 6.1 */ public enum AclCategory { @@ -112,4 +112,4 @@ public enum AclCategory { * scripting command */ SCRIPTING -} \ No newline at end of file +} diff --git a/src/main/java/io/lettuce/core/AclSetuserArgs.java b/src/main/java/io/lettuce/core/AclSetuserArgs.java index 5d38c27736..b03570632a 100644 --- a/src/main/java/io/lettuce/core/AclSetuserArgs.java +++ b/src/main/java/io/lettuce/core/AclSetuserArgs.java @@ -15,14 +15,14 @@ */ package io.lettuce.core; -import io.lettuce.core.protocol.CommandArgs; -import io.lettuce.core.protocol.CommandType; -import io.lettuce.core.protocol.ProtocolKeyword; +import static io.lettuce.core.protocol.CommandKeyword.*; import java.util.ArrayList; import java.util.List; -import static io.lettuce.core.protocol.CommandKeyword.*; +import io.lettuce.core.protocol.CommandArgs; +import io.lettuce.core.protocol.CommandType; +import io.lettuce.core.protocol.ProtocolKeyword; /** * Argument list builder for the Redis ACL SETUSER command. @@ -30,7 +30,7 @@ * {@link AclSetuserArgs} is a mutable object and instances should be used only once to avoid shared mutable state. * * @author Mikhael Sokolov - * @since 6.2 + * @since 6.1 */ public class AclSetuserArgs implements CompositeArgument { diff --git a/src/main/java/io/lettuce/core/CopyArgs.java b/src/main/java/io/lettuce/core/CopyArgs.java index aaaf3cf4d2..737b4d097e 100644 --- a/src/main/java/io/lettuce/core/CopyArgs.java +++ b/src/main/java/io/lettuce/core/CopyArgs.java @@ -25,7 +25,7 @@ * {@link CopyArgs} is a mutable object and instances should be used only once to avoid shared mutable state. * * @author Bartek Kowalczyk - * @since 6.2 + * @since 6.1 */ public class CopyArgs implements CompositeArgument { diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index 25c2cad6d2..d159d4da48 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -36,7 +36,12 @@ import io.lettuce.core.models.stream.PendingMessage; import io.lettuce.core.models.stream.PendingMessages; import io.lettuce.core.output.*; -import io.lettuce.core.protocol.*; +import io.lettuce.core.protocol.BaseRedisCommandBuilder; +import io.lettuce.core.protocol.Command; +import io.lettuce.core.protocol.CommandArgs; +import io.lettuce.core.protocol.CommandKeyword; +import io.lettuce.core.protocol.CommandType; +import io.lettuce.core.protocol.RedisCommand; /** * @param @@ -64,17 +69,17 @@ class RedisCommandBuilder extends BaseRedisCommandBuilder { super(codec); } - Command> aclCat() { + Command> aclCat() { CommandArgs args = new CommandArgs<>(codec); args.add(CAT); - return createCommand(ACL, new EnumListOutput<>(codec, AclCategory.class), args); + return createCommand(ACL, new EnumSetOutput<>(codec, AclCategory.class, String::toUpperCase, it -> null), args); } - Command> aclCat(AclCategory category) { + Command> aclCat(AclCategory category) { LettuceAssert.notNull(category, "Category " + MUST_NOT_BE_NULL); CommandArgs args = new CommandArgs<>(codec); args.add(CAT).add(category.name().toLowerCase()); - return createCommand(ACL, new EnumListOutput<>(codec, CommandType.class), args); + return createCommand(ACL, new EnumSetOutput<>(codec, CommandType.class, String::toUpperCase, it -> null), args); } Command aclDeluser(String... usernames) { @@ -99,11 +104,11 @@ Command aclGenpass(int bits) { return createCommand(ACL, new StatusOutput<>(codec), args); } - Command> aclGetuser(String username) { + Command> aclGetuser(String username) { LettuceAssert.notNull(username, "Username " + MUST_NOT_BE_NULL); CommandArgs args = new CommandArgs<>(codec); args.add(GETUSER).add(username); - return createCommand(ACL, new UserRulesOutput<>(codec), args); + return createCommand(ACL, new NestedMultiOutput<>(codec), args); } Command> aclList() { diff --git a/src/main/java/io/lettuce/core/api/async/RedisAclAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisAclAsyncCommands.java index beef094657..0a4b77f5a7 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisAclAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisAclAsyncCommands.java @@ -15,18 +15,18 @@ */ package io.lettuce.core.api.async; +import java.util.List; +import java.util.Map; +import java.util.Set; + import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.RedisFuture; import io.lettuce.core.protocol.CommandType; -import java.util.List; -import java.util.Map; - /** * Asynchronous executed commands for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateAsyncApi @@ -38,7 +38,7 @@ public interface RedisAclAsyncCommands { * * @return List<AclCategory> a list of ACL categories or */ - RedisFuture> aclCat(); + RedisFuture> aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -46,7 +46,7 @@ public interface RedisAclAsyncCommands { * @param category the specified category * @return List<CommandType> a list of commands inside a given category */ - RedisFuture> aclCat(AclCategory category); + RedisFuture> aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -77,7 +77,7 @@ public interface RedisAclAsyncCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - RedisFuture> aclGetuser(String username); + RedisFuture> aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -128,7 +128,7 @@ public interface RedisAclAsyncCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ RedisFuture aclSetuser(String username, AclSetuserArgs setuserArgs); diff --git a/src/main/java/io/lettuce/core/api/async/RedisKeyAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisKeyAsyncCommands.java index f929d761c4..ce1e921e18 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisKeyAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisKeyAsyncCommands.java @@ -50,7 +50,7 @@ public interface RedisKeyAsyncCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ RedisFuture copy(K source, K destination); @@ -61,7 +61,7 @@ public interface RedisKeyAsyncCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ RedisFuture copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java index 54296c4774..206f61b4d6 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java @@ -203,7 +203,7 @@ public interface RedisSortedSetAsyncCommands { * * @param keys the keys. * @return List<V> array-reply list of elements. - * @since 6.2 + * @since 6.1 */ RedisFuture> zdiff(K... keys); @@ -213,7 +213,7 @@ public interface RedisSortedSetAsyncCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ RedisFuture zdiffstore(K destKey, K... srcKeys); @@ -222,7 +222,7 @@ public interface RedisSortedSetAsyncCommands { * * @param keys the keys. * @return List<V> array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ RedisFuture>> zdiffWithScores(K... keys); @@ -765,7 +765,7 @@ public interface RedisSortedSetAsyncCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ RedisFuture zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -777,7 +777,7 @@ public interface RedisSortedSetAsyncCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ RedisFuture zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1242,7 +1242,7 @@ public interface RedisSortedSetAsyncCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ RedisFuture zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1254,7 +1254,7 @@ public interface RedisSortedSetAsyncCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ RedisFuture zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); 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 d0528c3cfe..3080c1e8a1 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisStringAsyncCommands.java @@ -18,7 +18,12 @@ import java.util.List; import java.util.Map; -import io.lettuce.core.*; +import io.lettuce.core.BitFieldArgs; +import io.lettuce.core.KeyValue; +import io.lettuce.core.RedisFuture; +import io.lettuce.core.SetArgs; +import io.lettuce.core.StrAlgoArgs; +import io.lettuce.core.StringMatchResult; import io.lettuce.core.output.KeyValueStreamingChannel; /** @@ -312,7 +317,7 @@ public interface RedisStringAsyncCommands { * @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 + * @since 6.1 */ RedisFuture setGet(K key, V value); @@ -323,7 +328,7 @@ public interface RedisStringAsyncCommands { * @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 + * @since 6.1 */ RedisFuture setGet(K key, V value, SetArgs setArgs); diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisAclReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisAclReactiveCommands.java index 14b465afaa..e6d0b0dbcf 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisAclReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisAclReactiveCommands.java @@ -15,18 +15,19 @@ */ package io.lettuce.core.api.reactive; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.protocol.CommandType; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.Map; /** * Reactive executed commands for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateReactiveApi @@ -38,7 +39,7 @@ public interface RedisAclReactiveCommands { * * @return AclCategory a list of ACL categories or */ - Flux aclCat(); + Mono> aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -46,7 +47,7 @@ public interface RedisAclReactiveCommands { * @param category the specified category * @return CommandType a list of commands inside a given category */ - Flux aclCat(AclCategory category); + Mono> aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -77,7 +78,7 @@ public interface RedisAclReactiveCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - Mono> aclGetuser(String username); + Mono> aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -128,7 +129,7 @@ public interface RedisAclReactiveCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ Mono aclSetuser(String username, AclSetuserArgs setuserArgs); diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisKeyReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisKeyReactiveCommands.java index 2a17c163ac..c261f11896 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisKeyReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisKeyReactiveCommands.java @@ -50,7 +50,7 @@ public interface RedisKeyReactiveCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Mono copy(K source, K destination); @@ -61,7 +61,7 @@ public interface RedisKeyReactiveCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Mono copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java index 40c1ffbd3e..f6f087119b 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java @@ -205,7 +205,7 @@ public interface RedisSortedSetReactiveCommands { * * @param keys the keys. * @return V array-reply list of elements. - * @since 6.2 + * @since 6.1 */ Flux zdiff(K... keys); @@ -215,7 +215,7 @@ public interface RedisSortedSetReactiveCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ Mono zdiffstore(K destKey, K... srcKeys); @@ -224,7 +224,7 @@ public interface RedisSortedSetReactiveCommands { * * @param keys the keys. * @return V array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ Flux> zdiffWithScores(K... keys); @@ -787,7 +787,7 @@ public interface RedisSortedSetReactiveCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Mono zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -799,7 +799,7 @@ public interface RedisSortedSetReactiveCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Mono zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1284,7 +1284,7 @@ public interface RedisSortedSetReactiveCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Mono zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1296,7 +1296,7 @@ public interface RedisSortedSetReactiveCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Mono zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); 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 1267e08399..0087eee571 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisStringReactiveCommands.java @@ -19,7 +19,12 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import io.lettuce.core.*; +import io.lettuce.core.BitFieldArgs; +import io.lettuce.core.KeyValue; +import io.lettuce.core.SetArgs; +import io.lettuce.core.StrAlgoArgs; +import io.lettuce.core.StringMatchResult; +import io.lettuce.core.Value; import io.lettuce.core.output.KeyValueStreamingChannel; /** @@ -315,7 +320,7 @@ public interface RedisStringReactiveCommands { * @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 + * @since 6.1 */ Mono setGet(K key, V value); @@ -326,7 +331,7 @@ public interface RedisStringReactiveCommands { * @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 + * @since 6.1 */ Mono setGet(K key, V value, SetArgs setArgs); diff --git a/src/main/java/io/lettuce/core/api/sync/RedisAclCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisAclCommands.java index 401146c4bd..c1e56f0194 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisAclCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisAclCommands.java @@ -15,17 +15,17 @@ */ package io.lettuce.core.api.sync; +import java.util.List; +import java.util.Map; +import java.util.Set; + import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.protocol.CommandType; -import java.util.List; -import java.util.Map; - /** * Synchronous executed commands for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateSyncApi @@ -37,7 +37,7 @@ public interface RedisAclCommands { * * @return List<AclCategory> a list of ACL categories or */ - List aclCat(); + Set aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -45,7 +45,7 @@ public interface RedisAclCommands { * @param category the specified category * @return List<CommandType> a list of commands inside a given category */ - List aclCat(AclCategory category); + Set aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -76,7 +76,7 @@ public interface RedisAclCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - Map aclGetuser(String username); + List aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -127,7 +127,7 @@ public interface RedisAclCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ String aclSetuser(String username, AclSetuserArgs setuserArgs); diff --git a/src/main/java/io/lettuce/core/api/sync/RedisKeyCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisKeyCommands.java index 9b034da9b7..5a6328d123 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisKeyCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisKeyCommands.java @@ -49,7 +49,7 @@ public interface RedisKeyCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Boolean copy(K source, K destination); @@ -60,7 +60,7 @@ public interface RedisKeyCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Boolean copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java index d6fcf2e08b..f2653749ce 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java @@ -203,7 +203,7 @@ public interface RedisSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of elements. - * @since 6.2 + * @since 6.1 */ List zdiff(K... keys); @@ -213,7 +213,7 @@ public interface RedisSortedSetCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ Long zdiffstore(K destKey, K... srcKeys); @@ -222,7 +222,7 @@ public interface RedisSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ List> zdiffWithScores(K... keys); @@ -765,7 +765,7 @@ public interface RedisSortedSetCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -777,7 +777,7 @@ public interface RedisSortedSetCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1242,7 +1242,7 @@ public interface RedisSortedSetCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1254,7 +1254,7 @@ public interface RedisSortedSetCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); 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 71871b885f..f79ed4dc08 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisStringCommands.java @@ -18,7 +18,11 @@ import java.util.List; import java.util.Map; -import io.lettuce.core.*; +import io.lettuce.core.BitFieldArgs; +import io.lettuce.core.KeyValue; +import io.lettuce.core.SetArgs; +import io.lettuce.core.StrAlgoArgs; +import io.lettuce.core.StringMatchResult; import io.lettuce.core.output.KeyValueStreamingChannel; /** @@ -312,7 +316,7 @@ public interface RedisStringCommands { * @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 + * @since 6.1 */ V setGet(K key, V value); @@ -323,7 +327,7 @@ public interface RedisStringCommands { * @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 + * @since 6.1 */ V setGet(K key, V value, SetArgs setArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionAclAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionAclAsyncCommands.java index 9293fce297..1abdc557ee 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionAclAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionAclAsyncCommands.java @@ -15,17 +15,17 @@ */ package io.lettuce.core.cluster.api.async; +import java.util.List; +import java.util.Map; +import java.util.Set; + import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.protocol.CommandType; -import java.util.List; -import java.util.Map; - /** * Asynchronous executed commands on a node selection for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateAsyncNodeSelectionClusterApi @@ -37,7 +37,7 @@ public interface NodeSelectionAclAsyncCommands { * * @return List<AclCategory> a list of ACL categories or */ - AsyncExecutions> aclCat(); + AsyncExecutions> aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -45,7 +45,7 @@ public interface NodeSelectionAclAsyncCommands { * @param category the specified category * @return List<CommandType> a list of commands inside a given category */ - AsyncExecutions> aclCat(AclCategory category); + AsyncExecutions> aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -76,7 +76,7 @@ public interface NodeSelectionAclAsyncCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - AsyncExecutions> aclGetuser(String username); + AsyncExecutions> aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -127,7 +127,7 @@ public interface NodeSelectionAclAsyncCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ AsyncExecutions aclSetuser(String username, AclSetuserArgs setuserArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionKeyAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionKeyAsyncCommands.java index 3ebcf29389..8b1fdc3239 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionKeyAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionKeyAsyncCommands.java @@ -49,7 +49,7 @@ public interface NodeSelectionKeyAsyncCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ AsyncExecutions copy(K source, K destination); @@ -60,7 +60,7 @@ public interface NodeSelectionKeyAsyncCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ AsyncExecutions copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java index d3137faace..91267d6e37 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java @@ -203,7 +203,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * * @param keys the keys. * @return List<V> array-reply list of elements. - * @since 6.2 + * @since 6.1 */ AsyncExecutions> zdiff(K... keys); @@ -213,7 +213,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ AsyncExecutions zdiffstore(K destKey, K... srcKeys); @@ -222,7 +222,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * * @param keys the keys. * @return List<V> array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ AsyncExecutions>> zdiffWithScores(K... keys); @@ -765,7 +765,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ AsyncExecutions zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -777,7 +777,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ AsyncExecutions zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1242,7 +1242,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ AsyncExecutions zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1254,7 +1254,7 @@ public interface NodeSelectionSortedSetAsyncCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ AsyncExecutions zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); 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 24fa588532..f6dbe06a60 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 @@ -18,7 +18,11 @@ import java.util.List; import java.util.Map; -import io.lettuce.core.*; +import io.lettuce.core.BitFieldArgs; +import io.lettuce.core.KeyValue; +import io.lettuce.core.SetArgs; +import io.lettuce.core.StrAlgoArgs; +import io.lettuce.core.StringMatchResult; import io.lettuce.core.output.KeyValueStreamingChannel; /** @@ -312,7 +316,7 @@ public interface NodeSelectionStringAsyncCommands { * @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 + * @since 6.1 */ AsyncExecutions setGet(K key, V value); @@ -323,7 +327,7 @@ public interface NodeSelectionStringAsyncCommands { * @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 + * @since 6.1 */ AsyncExecutions setGet(K key, V value, SetArgs setArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionAclCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionAclCommands.java index e6b2535391..197da0a096 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionAclCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionAclCommands.java @@ -15,17 +15,17 @@ */ package io.lettuce.core.cluster.api.sync; +import java.util.List; +import java.util.Map; +import java.util.Set; + import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.protocol.CommandType; -import java.util.List; -import java.util.Map; - /** * Synchronous executed commands on a node selection for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateSyncNodeSelectionClusterApi @@ -37,7 +37,7 @@ public interface NodeSelectionAclCommands { * * @return List<AclCategory> a list of ACL categories or */ - Executions> aclCat(); + Executions> aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -45,7 +45,7 @@ public interface NodeSelectionAclCommands { * @param category the specified category * @return List<CommandType> a list of commands inside a given category */ - Executions> aclCat(AclCategory category); + Executions> aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -76,7 +76,7 @@ public interface NodeSelectionAclCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - Executions> aclGetuser(String username); + Executions> aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -127,7 +127,7 @@ public interface NodeSelectionAclCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ Executions aclSetuser(String username, AclSetuserArgs setuserArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionKeyCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionKeyCommands.java index fc9d8c1261..52fc65f095 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionKeyCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionKeyCommands.java @@ -49,7 +49,7 @@ public interface NodeSelectionKeyCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Executions copy(K source, K destination); @@ -60,7 +60,7 @@ public interface NodeSelectionKeyCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Executions copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java index 00d404d013..3f1de597b2 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java @@ -203,7 +203,7 @@ public interface NodeSelectionSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of elements. - * @since 6.2 + * @since 6.1 */ Executions> zdiff(K... keys); @@ -213,7 +213,7 @@ public interface NodeSelectionSortedSetCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ Executions zdiffstore(K destKey, K... srcKeys); @@ -222,7 +222,7 @@ public interface NodeSelectionSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ Executions>> zdiffWithScores(K... keys); @@ -765,7 +765,7 @@ public interface NodeSelectionSortedSetCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Executions zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -777,7 +777,7 @@ public interface NodeSelectionSortedSetCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Executions zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1242,7 +1242,7 @@ public interface NodeSelectionSortedSetCommands { * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Executions zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1254,7 +1254,7 @@ public interface NodeSelectionSortedSetCommands { * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Executions zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); 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 2efca005a2..e88f8107bb 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 @@ -18,7 +18,11 @@ import java.util.List; import java.util.Map; -import io.lettuce.core.*; +import io.lettuce.core.BitFieldArgs; +import io.lettuce.core.KeyValue; +import io.lettuce.core.SetArgs; +import io.lettuce.core.StrAlgoArgs; +import io.lettuce.core.StringMatchResult; import io.lettuce.core.output.KeyValueStreamingChannel; /** @@ -312,7 +316,7 @@ public interface NodeSelectionStringCommands { * @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 + * @since 6.1 */ Executions setGet(K key, V value); @@ -323,7 +327,7 @@ public interface NodeSelectionStringCommands { * @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 + * @since 6.1 */ Executions setGet(K key, V value, SetArgs setArgs); diff --git a/src/main/java/io/lettuce/core/output/EnumListOutput.java b/src/main/java/io/lettuce/core/output/EnumListOutput.java deleted file mode 100644 index a899fd68f1..0000000000 --- a/src/main/java/io/lettuce/core/output/EnumListOutput.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.lettuce.core.output; - -import io.lettuce.core.codec.RedisCodec; -import io.lettuce.core.internal.LettuceAssert; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.List; - -/** - * {@link List} of enums output. - * - * @param Key type. - * @param Value type. - * @author Mikhael Sokolov - */ -public class EnumListOutput> extends CommandOutput> implements StreamingOutput { - - private boolean initialized; - - private Subscriber subscriber; - - private final Class enumClass; - - public EnumListOutput(RedisCodec codec, Class enumClass) { - super(codec, Collections.emptyList()); - setSubscriber(ListSubscriber.instance()); - this.enumClass = enumClass; - } - - @Override - public void set(ByteBuffer bytes) { - subscriber.onNext(output, bytes == null ? null : valueOfOrNull(decodeAscii(bytes))); - } - - @Override - public void multi(int count) { - - if (!initialized) { - output = OutputFactory.newList(count); - initialized = true; - } - } - - @Override - public void setSubscriber(Subscriber subscriber) { - LettuceAssert.notNull(subscriber, "Subscriber must not be null"); - this.subscriber = subscriber; - } - - @Override - public Subscriber getSubscriber() { - return subscriber; - } - - private E valueOfOrNull(String value) { - try { - return Enum.valueOf(enumClass, value.toLowerCase()); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/src/main/java/io/lettuce/core/output/EnumSetOutput.java b/src/main/java/io/lettuce/core/output/EnumSetOutput.java new file mode 100644 index 0000000000..dd2c1c40fe --- /dev/null +++ b/src/main/java/io/lettuce/core/output/EnumSetOutput.java @@ -0,0 +1,80 @@ +package io.lettuce.core.output; + +import java.nio.ByteBuffer; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; +import java.util.function.Function; +import java.util.function.UnaryOperator; + +import io.lettuce.core.codec.RedisCodec; + +/** + * {@link EnumSet} output. + * + * @param Key type. + * @param Value type. + * @author Mikhael Sokolov + * @author Mark Paluch + * @since 6.1 + */ +public class EnumSetOutput> extends CommandOutput> { + + private boolean initialized; + + private final Class enumClass; + + private final UnaryOperator enumValuePreprocessor; + + private final Function onUnknownValue; + + /** + * Create a new {@link EnumSetOutput}. + * + * @param codec Codec used to encode/decode keys and values, must not be {@code null}. + * @param enumClass {@link Enum} type. + * @param enumValuePreprocessor pre-processor for {@link String} values before looking up the enum value. + * @param onUnknownValue fallback {@link Function} to be called when an enum value cannot be looked up. + */ + public EnumSetOutput(RedisCodec codec, Class enumClass, UnaryOperator enumValuePreprocessor, + Function onUnknownValue) { + super(codec, Collections.emptySet()); + this.enumClass = enumClass; + this.enumValuePreprocessor = enumValuePreprocessor; + this.onUnknownValue = onUnknownValue; + } + + @Override + public void set(ByteBuffer bytes) { + + if (bytes == null) { + return; + } + + E enumConstant = resolve(enumValuePreprocessor.apply(decodeAscii(bytes))); + + if (enumConstant == null) { + return; + } + + output.add(enumConstant); + } + + @Override + public void multi(int count) { + + if (!initialized) { + output = EnumSet.noneOf(enumClass); + initialized = true; + } + } + + private E resolve(String value) { + try { + return Enum.valueOf(enumClass, value); + } catch (IllegalArgumentException e) { + return onUnknownValue.apply(value); + } + } + +} diff --git a/src/main/java/io/lettuce/core/output/ListOfGenericMapsOutput.java b/src/main/java/io/lettuce/core/output/ListOfGenericMapsOutput.java index 8c461ef9c9..679b24de62 100644 --- a/src/main/java/io/lettuce/core/output/ListOfGenericMapsOutput.java +++ b/src/main/java/io/lettuce/core/output/ListOfGenericMapsOutput.java @@ -15,25 +15,26 @@ */ package io.lettuce.core.output; -import io.lettuce.core.codec.RedisCodec; - import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import io.lettuce.core.codec.RedisCodec; + /** * {@link List} of maps output. * * @param Key type. * @param Value type. - * - * @author Will Glozer + * @author Mikhael Sokolov + * @since 6.1 + * @see GenericMapOutput */ public class ListOfGenericMapsOutput extends CommandOutput>> { - private GenericMapOutput nested; + private final GenericMapOutput nested; private int mapCount = -1; @@ -84,4 +85,4 @@ public void set(long integer) { public void set(double number) { nested.set(number); } -} \ No newline at end of file +} diff --git a/src/main/java/io/lettuce/core/output/UserRulesOutput.java b/src/main/java/io/lettuce/core/output/UserRulesOutput.java deleted file mode 100644 index 49e0fc2808..0000000000 --- a/src/main/java/io/lettuce/core/output/UserRulesOutput.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2019-2021 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.lettuce.core.output; - -import io.lettuce.core.codec.RedisCodec; - -import java.nio.ByteBuffer; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * {@link Map} of usernames and rules output. - * - * @param Key type. - * @param Value type. - * - * @author Mikhael Sokolov - */ -public class UserRulesOutput extends CommandOutput> { - - private String username; - - public UserRulesOutput(RedisCodec codec) { - super(codec, null); - } - - @Override - public void set(ByteBuffer bytes) { - if (username == null) { - username = (bytes == null) ? null : decodeAscii(bytes); - return; - } - - Object value = (bytes == null) ? null : codec.decodeValue(bytes); - output.put(username, value); - username = null; - } - - @Override - public void setBigNumber(ByteBuffer bytes) { - set(bytes); - } - - @Override - @SuppressWarnings("unchecked") - public void set(long integer) { - - if (username == null) { - username = String.valueOf(integer); - return; - } - - V value = (V) Long.valueOf(integer); - output.put(username, value); - username = null; - } - - @Override - public void set(double number) { - - if (username == null) { - username = String.valueOf(number); - return; - } - - Object value = number; - output.put(username, value); - username = null; - } - - @Override - public void multi(int count) { - if (output == null) { - output = new LinkedHashMap<>(count / 2, 1); - } - } -} diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommands.kt index 6c9533aeb2..74d3edb008 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommands.kt @@ -16,16 +16,16 @@ package io.lettuce.core.api.coroutines +import io.lettuce.core.AclCategory +import io.lettuce.core.AclSetuserArgs import io.lettuce.core.ExperimentalLettuceCoroutinesApi -import kotlinx.coroutines.flow.Flow -import io.lettuce.core.* import io.lettuce.core.protocol.CommandType +import kotlinx.coroutines.flow.Flow /** * Coroutine executed commands for the ACL-API. * * @author Mikhael Sokolov - * @author Mikhael Sokolov * @since 6.1 * @generated by io.lettuce.apigenerator.CreateKotlinCoroutinesApi */ @@ -37,7 +37,7 @@ interface RedisAclCoroutinesCommands { * * @return List a list of ACL categories or */ - suspend fun aclCat(): List + suspend fun aclCat(): Set /** * The command shows all the Redis commands in the specified category. @@ -45,7 +45,7 @@ interface RedisAclCoroutinesCommands { * @param category the specified category * @return List a list of commands inside a given category */ - suspend fun aclCat(category: AclCategory): List + suspend fun aclCat(category: AclCategory): Set /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -76,7 +76,7 @@ interface RedisAclCoroutinesCommands { * @param username the specified username * @return Map a map of ACL rule definitions for the user. */ - suspend fun aclGetuser(username: String): Map? + suspend fun aclGetuser(username: String): List /** * The command shows the currently active ACL rules in the Redis server. @@ -127,7 +127,7 @@ interface RedisAclCoroutinesCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ suspend fun aclSetuser(username: String, setuserArgs: AclSetuserArgs): String? diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommandsImpl.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommandsImpl.kt index 6fb95323e2..5af18a1970 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommandsImpl.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisAclCoroutinesCommandsImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2021 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. @@ -24,9 +24,10 @@ import io.lettuce.core.protocol.CommandType import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList import kotlinx.coroutines.reactive.asFlow +import kotlinx.coroutines.reactive.awaitFirst +import kotlinx.coroutines.reactive.awaitFirstOrElse import kotlinx.coroutines.reactive.awaitFirstOrNull - /** * Coroutine executed commands (based on reactive commands) for basic commands. * @@ -38,9 +39,11 @@ import kotlinx.coroutines.reactive.awaitFirstOrNull @ExperimentalLettuceCoroutinesApi internal class RedisAclCoroutinesCommandsImpl(internal val ops: RedisAclReactiveCommands) : RedisAclCoroutinesCommands { - override suspend fun aclCat(): List = ops.aclCat().asFlow().toList() + override suspend fun aclCat(): Set = + ops.aclCat().awaitFirstOrElse { emptySet() } - override suspend fun aclCat(category: AclCategory): List = ops.aclCat(category).asFlow().toList() + override suspend fun aclCat(category: AclCategory): Set = + ops.aclCat(category).awaitFirstOrElse { emptySet() } override suspend fun aclDeluser(vararg usernames: String): Long? = ops.aclDeluser(*usernames).awaitFirstOrNull() @@ -48,7 +51,8 @@ internal class RedisAclCoroutinesCommandsImpl(internal val ops override suspend fun aclGenpass(bits: Int): String? = ops.aclGenpass(bits).awaitFirstOrNull() - override suspend fun aclGetuser(username: String): Map? = ops.aclGetuser(username).awaitFirstOrNull() + override suspend fun aclGetuser(username: String): List = + ops.aclGetuser(username).awaitFirst() override fun aclList(): Flow = ops.aclList().asFlow() diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisKeyCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisKeyCoroutinesCommands.kt index 7d83c8177b..bfd04c42a0 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisKeyCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisKeyCoroutinesCommands.kt @@ -40,7 +40,7 @@ interface RedisKeyCoroutinesCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: `true` if source was copied. `false` if source was not copied. - * @since 6.2 + * @since 6. */ suspend fun copy(source: K, destination: K): Boolean? @@ -51,7 +51,7 @@ interface RedisKeyCoroutinesCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: `true` if source was copied. `false` if source was not copied. - * @since 6.2 + * @since 6.1 */ suspend fun copy(source: K, destination: K, copyArgs: CopyArgs): Boolean? diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt index d7488556e4..bb7e59ca10 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt @@ -175,29 +175,29 @@ interface RedisSortedSetCoroutinesCommands { /** * Computes the difference between the first and all successive input sorted sets. - * - * @param keys the keys. - * @return List array-reply list of elements. - * @since 6.2 + * + * @param keys the keys. + * @return List array-reply list of elements. + * @since 6.1 */ fun zdiff(vararg keys: K): Flow /** - * Computes the difference between the first and all successive input sorted sets and stores the result in destination. - * - * @param destKey the dest key. - * @param srcKeys the src keys. - * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * Computes the difference between the first and all successive input sorted sets and stores the result in destination. + * + * @param destKey the dest key. + * @param srcKeys the src keys. + * @return Long the number of elements in the resulting sorted set at destination. + * @since 6.1 */ suspend fun zdiffstore(destKey: K, vararg srcKeys: K): Long? /** - * Computes the difference between the first and all successive input sorted sets. - * - * @param keys the keys. - * @return List array-reply list of scored values. - * @since 6.2 + * Computes the difference between the first and all successive input sorted sets. + * + * @param keys the keys. + * @return List array-reply list of scored values. + * @since 6.1 */ fun zdiffWithScores(vararg keys: K): Flow> @@ -414,24 +414,24 @@ interface RedisSortedSetCoroutinesCommands { fun zrangebyscoreWithScores(key: K, range: Range, limit: Limit): Flow> /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. - * - * @param dstKey the dst key. - * @param srcKey the src key. - * @param range the lexicographical range. - * @return The number of elements in the resulting sorted set. - * @since 6.2 + * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * + * @param dstKey the dst key. + * @param srcKey the src key. + * @param range the lexicographical range. + * @return The number of elements in the resulting sorted set. + * @since 6.1 */ suspend fun zrangestorebylex(dstKey: K, srcKey: K, range: Range, limit: Limit): Long? /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. - * - * @param dstKey the dst key. - * @param srcKey the src key. - * @param range the score range. - * @return The number of elements in the resulting sorted set. - * @since 6.2 + * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * + * @param dstKey the dst key. + * @param srcKey the src key. + * @param range the score range. + * @return The number of elements in the resulting sorted set. + * @since 6.1 */ suspend fun zrangestorebyscore(dstKey: K, srcKey: K, range: Range, limit: Limit): Long? @@ -570,24 +570,24 @@ interface RedisSortedSetCoroutinesCommands { fun zrevrangebyscoreWithScores(key: K, range: Range, limit: Limit): Flow> /** - * Get the lexicographical range ordered from high to low of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. - * - * @param dstKey the src key. - * @param srcKey the dst key. - * @param range the lexicographical range. - * @return The number of elements in the resulting sorted set. - * @since 6.2 + * Get the lexicographical range ordered from high to low of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * + * @param dstKey the src key. + * @param srcKey the dst key. + * @param range the lexicographical range. + * @return The number of elements in the resulting sorted set. + * @since 6.1 */ suspend fun zrevrangestorebylex(dstKey: K, srcKey: K, range: Range, limit: Limit): Long? /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} with scores ordered from high to low and stores the result in the {@code dstKey} destination key. - * - * @param dstKey the src key. - * @param srcKey the dst key. - * @param range the score range. - * @return The number of elements in the resulting sorted set. - * @since 6.2 + * Get the specified range of elements in the sorted set stored at {@code srcKey} with scores ordered from high to low and stores the result in the {@code dstKey} destination key. + * + * @param dstKey the src key. + * @param srcKey the dst key. + * @param range the score range. + * @return The number of elements in the resulting sorted set. + * @since 6.1 */ suspend fun zrevrangestorebyscore(dstKey: K, srcKey: K, range: Range, limit: Limit): Long? 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 8909f649fd..f29c86f1c3 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisStringCoroutinesCommands.kt @@ -298,22 +298,22 @@ interface RedisStringCoroutinesCommands { /** * 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 + * + * @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.1 */ 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 + * 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.1 */ suspend fun setGet(key: K, value: V, setArgs: SetArgs): V? diff --git a/src/main/templates/io/lettuce/core/api/RedisAclCommands.java b/src/main/templates/io/lettuce/core/api/RedisAclCommands.java index 66d36ec2bf..442c37dde0 100644 --- a/src/main/templates/io/lettuce/core/api/RedisAclCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisAclCommands.java @@ -25,7 +25,6 @@ /** * ${intent} for the ACL-API. * - * @author Mark Paluch * @author Mikhael Sokolov * @since 6.1 */ @@ -36,7 +35,7 @@ public interface RedisAclCommands { * * @return List<AclCategory> a list of ACL categories or */ - List aclCat(); + Set aclCat(); /** * The command shows all the Redis commands in the specified category. @@ -44,7 +43,7 @@ public interface RedisAclCommands { * @param category the specified category * @return List<CommandType> a list of commands inside a given category */ - List aclCat(AclCategory category); + Set aclCat(AclCategory category); /** * Delete all the specified ACL users and terminate all the connections that are authenticated with such users. @@ -75,7 +74,7 @@ public interface RedisAclCommands { * @param username the specified username * @return Map<String, Object> a map of ACL rule definitions for the user. */ - Map aclGetuser(String username); + List aclGetuser(String username); /** * The command shows the currently active ACL rules in the Redis server. @@ -126,7 +125,7 @@ public interface RedisAclCommands { * Create an ACL user with the specified rules or modify the rules of an existing user. * * @param username the specified username - * @param rules rules + * @param setuserArgs rules * @return String simple-string-reply OK or error message. */ String aclSetuser(String username, AclSetuserArgs setuserArgs); @@ -144,4 +143,4 @@ public interface RedisAclCommands { * @return K bulk-string-reply the username of the current connection. */ String aclWhoami(); -} \ No newline at end of file +} diff --git a/src/main/templates/io/lettuce/core/api/RedisKeyCommands.java b/src/main/templates/io/lettuce/core/api/RedisKeyCommands.java index 9f738fa24c..602a7ed23a 100644 --- a/src/main/templates/io/lettuce/core/api/RedisKeyCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisKeyCommands.java @@ -41,7 +41,7 @@ public interface RedisKeyCommands { * @param source the source. * @param destination the destination. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Boolean copy(K source, K destination); @@ -52,7 +52,7 @@ public interface RedisKeyCommands { * @param destination the destination. * @param copyArgs the copyArgs. * @return Boolean integer-reply specifically: {@code true} if source was copied. {@code false} if source was not copied. - * @since 6.2 + * @since 6.1 */ Boolean copy(K source, K destination, CopyArgs copyArgs); diff --git a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java index 51bcf55b76..124c494a1c 100644 --- a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java @@ -202,7 +202,7 @@ public interface RedisSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of elements. - * @since 6.2 + * @since 6.1 */ List zdiff(K... keys); @@ -212,7 +212,7 @@ public interface RedisSortedSetCommands { * @param destKey the dest key. * @param srcKeys the src keys. * @return Long the number of elements in the resulting sorted set at destination. - * @since 6.2 + * @since 6.1 */ Long zdiffstore(K destKey, K... srcKeys); @@ -221,7 +221,7 @@ public interface RedisSortedSetCommands { * * @param keys the keys. * @return List<V> array-reply list of scored values. - * @since 6.2 + * @since 6.1 */ List> zdiffWithScores(K... keys); @@ -765,7 +765,7 @@ Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Stri * @param srcKey the src key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -776,7 +776,7 @@ Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Stri * @param srcKey the src key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); @@ -1242,7 +1242,7 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S * @param srcKey the dst key. * @param range the lexicographical range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); @@ -1253,7 +1253,7 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S * @param srcKey the dst key. * @param range the score range. * @return The number of elements in the resulting sorted set. - * @since 6.2 + * @since 6.1 */ Long zrevrangestorebyscore(K dstKey, K srcKey, Range range, Limit limit); diff --git a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java index ef40ccbf68..c50a65e446 100644 --- a/src/main/templates/io/lettuce/core/api/RedisStringCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisStringCommands.java @@ -311,7 +311,7 @@ public interface RedisStringCommands { * @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 + * @since 6.1 */ V setGet(K key, V value); @@ -322,7 +322,7 @@ public interface RedisStringCommands { * @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 + * @since 6.1 */ V setGet(K key, V value, SetArgs setArgs); diff --git a/src/test/java/io/lettuce/apigenerator/Constants.java b/src/test/java/io/lettuce/apigenerator/Constants.java index 25075f4308..4772f1c4f8 100644 --- a/src/test/java/io/lettuce/apigenerator/Constants.java +++ b/src/test/java/io/lettuce/apigenerator/Constants.java @@ -24,6 +24,7 @@ class Constants { public static final String[] TEMPLATE_NAMES = { "BaseRedisCommands", + "RedisAclCommands", "RedisGeoCommands", "RedisHashCommands", "RedisHLLCommands", diff --git a/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java b/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java index 3ad811eea4..36d34e1cb1 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java @@ -16,7 +16,11 @@ package io.lettuce.apigenerator; import java.io.File; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; @@ -53,6 +57,9 @@ public class CreateReactiveApi { Map resultSpec = new HashMap<>(); resultSpec.put("geopos", "Flux>"); + resultSpec.put("aclCat()", "Mono>"); + resultSpec.put("aclCat(AclCategory category)", "Mono>"); + resultSpec.put("aclGetuser", "Mono>"); resultSpec.put("bitfield", "Flux>"); resultSpec.put("hgetall", "Flux>"); resultSpec.put("zmscore", "Mono>"); // Redis returns null if element was not found diff --git a/src/test/java/io/lettuce/core/commands/AclCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/AclCommandIntegrationTests.java index 3b1cdb504b..0e85a3a9c8 100644 --- a/src/test/java/io/lettuce/core/commands/AclCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/AclCommandIntegrationTests.java @@ -15,6 +15,15 @@ */ package io.lettuce.core.commands; +import static org.assertj.core.api.Assertions.*; + +import javax.inject.Inject; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.extension.ExtendWith; + import io.lettuce.core.AclCategory; import io.lettuce.core.AclSetuserArgs; import io.lettuce.core.RedisCommandExecutionException; @@ -23,18 +32,12 @@ import io.lettuce.core.protocol.CommandType; import io.lettuce.test.LettuceExtension; import io.lettuce.test.condition.EnabledOnCommand; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.extension.ExtendWith; - -import javax.inject.Inject; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; /** + * Integration tests for ACL commands. + * * @author Mikhael Sokolov + * @author Mark Paluch */ @ExtendWith(LettuceExtension.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -57,7 +60,7 @@ void setUp() { } @Test - void aclCat() { + public void aclCat() { assertThat(redis.aclCat()).isNotEmpty(); assertThat(redis.aclCat(AclCategory.SLOW)).isNotEmpty(); } @@ -75,7 +78,7 @@ void aclGenpass() { @Test void aclGetuser() { - assertThat(redis.aclGetuser("default")).hasFieldOrProperty("flags"); + assertThat(redis.aclGetuser("default")).contains("flags"); } @Test @@ -91,7 +94,7 @@ void aclLog() { assertThat(redis.aclLog()).hasSize(2).first().hasFieldOrProperty("reason"); assertThat(redis.aclLog(1)).hasSize(1); assertThat(redis.aclLogReset()).isEqualTo("OK"); - assertThat(redis.aclLog()).hasSize(0); + assertThat(redis.aclLog()).isEmpty(); } @Test @@ -109,7 +112,7 @@ void aclSetuser() { assertThat(redis.aclDeluser("foo")).isNotNull(); AclSetuserArgs args = AclSetuserArgs.Builder.on().addCommand(CommandType.GET).keyPattern("objects:*").addPassword("foobared"); assertThat(redis.aclSetuser("foo", args)).isEqualTo("OK"); - assertThat(redis.aclGetuser("foo")).containsKey("commands").containsKey("passwords").containsKey("keys"); + assertThat(redis.aclGetuser("foo")).contains("commands").contains("passwords").contains("keys"); assertThat(redis.aclDeluser("foo")).isNotNull(); } diff --git a/src/test/java/io/lettuce/core/commands/reactive/AclReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/AclReactiveCommandIntegrationTests.java new file mode 100644 index 0000000000..aeea21d529 --- /dev/null +++ b/src/test/java/io/lettuce/core/commands/reactive/AclReactiveCommandIntegrationTests.java @@ -0,0 +1,36 @@ +/* + * Copyright 2011-2021 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.lettuce.core.commands.reactive; + +import javax.inject.Inject; + +import io.lettuce.core.api.StatefulRedisConnection; +import io.lettuce.core.commands.AclCommandIntegrationTests; +import io.lettuce.test.ReactiveSyncInvocationHandler; + +/** + * Integration tests though the reactive facade for {@link AclCommandIntegrationTests}. + * + * @author Mark Paluch + */ +class AclReactiveCommandIntegrationTests extends AclCommandIntegrationTests { + + @Inject + AclReactiveCommandIntegrationTests(StatefulRedisConnection connection) { + super(ReactiveSyncInvocationHandler.sync(connection)); + } + +}