diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index 462e5e539f..1a5e4d1645 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -979,8 +979,7 @@ Command expire(K key, long seconds, ExpireArgs expireArgs) { } Command> hexpire(K key, long seconds, ExpireArgs expireArgs, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).add(seconds); @@ -994,8 +993,7 @@ Command> hexpire(K key, long seconds, ExpireArgs expireArgs, K. } Command> hexpireat(K key, long seconds, ExpireArgs expireArgs, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).add(seconds); @@ -1009,8 +1007,7 @@ Command> hexpireat(K key, long seconds, ExpireArgs expireArgs, } Command> httl(K key, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key); args.add(FIELDS).add(fields.length).addKeys(fields); @@ -1019,8 +1016,7 @@ Command> httl(K key, K... fields) { } Command> hpexpire(K key, long milliseconds, ExpireArgs expireArgs, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).add(milliseconds); @@ -1034,8 +1030,7 @@ Command> hpexpire(K key, long milliseconds, ExpireArgs expireAr } Command> hpexpireat(K key, long timestamp, ExpireArgs expireArgs, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).add(timestamp); @@ -1049,8 +1044,7 @@ Command> hpexpireat(K key, long timestamp, ExpireArgs expireArg } Command> hpexpiretime(K key, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key); args.add(FIELDS).add(fields.length).addKeys(fields); @@ -1059,8 +1053,7 @@ Command> hpexpiretime(K key, K... fields) { } Command> hpttl(K key, K... fields) { - notNullKey(key); - notEmpty(fields); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key); args.add(FIELDS).add(fields.length).addKeys(fields); @@ -1460,9 +1453,7 @@ Command getset(K key, V value) { } Command hdel(K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); return createCommand(HDEL, new IntegerOutput<>(codec), args); @@ -1554,18 +1545,15 @@ Command hlen(K key) { } Command> hmget(K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); return createCommand(HMGET, new ValueListOutput<>(codec), args); } Command hmget(ValueStreamingChannel channel, K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + keyAndFieldsProvided(key, fields); + notNull(channel); CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); @@ -1573,9 +1561,8 @@ Command hmget(ValueStreamingChannel channel, K key, K... fields) } Command hmget(KeyValueStreamingChannel channel, K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + keyAndFieldsProvided(key, fields); + notNull(channel); CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); @@ -1583,9 +1570,7 @@ Command hmget(KeyValueStreamingChannel channel, K key, K... fi } Command>> hmgetKeyValue(K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + keyAndFieldsProvided(key, fields); CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); return createCommand(HMGET, new KeyValueListOutput<>(codec, Arrays.asList(fields)), args); @@ -4561,6 +4546,11 @@ private static void notNullKey(Object key) { LettuceAssert.notNull(key, "Key " + MUST_NOT_BE_NULL); } + private static void keyAndFieldsProvided(Object key, Object[] fields) { + LettuceAssert.notNull(key, "Key " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + } + private static void notNullLimit(Limit limit) { LettuceAssert.notNull(limit, "Limit " + MUST_NOT_BE_NULL); } diff --git a/src/main/java/io/lettuce/core/api/async/RedisHashAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisHashAsyncCommands.java index 860f68017d..cf5212ccda 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisHashAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisHashAsyncCommands.java @@ -599,6 +599,7 @@ RedisFuture hscanNovalues(KeyStreamingChannel channel, K ke * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ RedisFuture> hpersist(K key, K... fields); diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisHashReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisHashReactiveCommands.java index 3e5c616d60..339d1c4b19 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisHashReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisHashReactiveCommands.java @@ -629,6 +629,7 @@ public interface RedisHashReactiveCommands { * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ Flux hpersist(K key, K... fields); diff --git a/src/main/java/io/lettuce/core/api/sync/RedisHashCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisHashCommands.java index e46ce71a29..881de7ae05 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisHashCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisHashCommands.java @@ -596,6 +596,7 @@ public interface RedisHashCommands { * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ List hpersist(K key, K... fields); diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionHashAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionHashAsyncCommands.java index 385ecdc5dc..241ce174b6 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionHashAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionHashAsyncCommands.java @@ -598,6 +598,7 @@ AsyncExecutions hscanNovalues(KeyStreamingChannel channel, * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ AsyncExecutions> hpersist(K key, K... fields); diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionHashCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionHashCommands.java index bf710986dc..72b2833a91 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionHashCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionHashCommands.java @@ -596,6 +596,7 @@ public interface NodeSelectionHashCommands { * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ Executions> hpersist(K key, K... fields); diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisHashCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisHashCoroutinesCommands.kt index dd9bc72fb3..6900ded990 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisHashCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisHashCoroutinesCommands.kt @@ -470,6 +470,7 @@ interface RedisHashCoroutinesCommands { * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: `1` indicating expiration time is removed; * `-1` field has no expiration time to be removed; `-2` indicating there is no such field + * @since 7.0 */ suspend fun hpersist(key: K, vararg fields: K): List diff --git a/src/main/templates/io/lettuce/core/api/RedisHashCommands.java b/src/main/templates/io/lettuce/core/api/RedisHashCommands.java index 16eed70102..bcf6b35ac9 100644 --- a/src/main/templates/io/lettuce/core/api/RedisHashCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisHashCommands.java @@ -591,6 +591,7 @@ public interface RedisHashCommands { * @param fields one or more fields to remove the TTL for. * @return a {@List} of {@Long} values for each of the fields provided: {@code 1} indicating expiration time is removed; * {@code -1} field has no expiration time to be removed; {@code -2} indicating there is no such field + * @since 7.0 */ List hpersist(K key, K... fields);