Skip to content

Commit

Permalink
Polishing - addressed Ali's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun committed May 21, 2024
1 parent 8b59ebd commit 9953306
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 29 deletions.
48 changes: 19 additions & 29 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,7 @@ Command<K, V, Boolean> expire(K key, long seconds, ExpireArgs expireArgs) {
}

Command<K, V, List<Long>> hexpire(K key, long seconds, ExpireArgs expireArgs, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key).add(seconds);

Expand All @@ -994,8 +993,7 @@ Command<K, V, List<Long>> hexpire(K key, long seconds, ExpireArgs expireArgs, K.
}

Command<K, V, List<Long>> hexpireat(K key, long seconds, ExpireArgs expireArgs, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key).add(seconds);

Expand All @@ -1009,8 +1007,7 @@ Command<K, V, List<Long>> hexpireat(K key, long seconds, ExpireArgs expireArgs,
}

Command<K, V, List<Long>> httl(K key, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
args.add(FIELDS).add(fields.length).addKeys(fields);
Expand All @@ -1019,8 +1016,7 @@ Command<K, V, List<Long>> httl(K key, K... fields) {
}

Command<K, V, List<Long>> hpexpire(K key, long milliseconds, ExpireArgs expireArgs, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key).add(milliseconds);

Expand All @@ -1034,8 +1030,7 @@ Command<K, V, List<Long>> hpexpire(K key, long milliseconds, ExpireArgs expireAr
}

Command<K, V, List<Long>> hpexpireat(K key, long timestamp, ExpireArgs expireArgs, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key).add(timestamp);

Expand All @@ -1049,8 +1044,7 @@ Command<K, V, List<Long>> hpexpireat(K key, long timestamp, ExpireArgs expireArg
}

Command<K, V, List<Long>> hpexpiretime(K key, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
args.add(FIELDS).add(fields.length).addKeys(fields);
Expand All @@ -1059,8 +1053,7 @@ Command<K, V, List<Long>> hpexpiretime(K key, K... fields) {
}

Command<K, V, List<Long>> hpttl(K key, K... fields) {
notNullKey(key);
notEmpty(fields);
keyAndFieldsProvided(key, fields);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
args.add(FIELDS).add(fields.length).addKeys(fields);
Expand Down Expand Up @@ -1460,9 +1453,7 @@ Command<K, V, V> getset(K key, V value) {
}

Command<K, V, Long> 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<K, V> args = new CommandArgs<>(codec).addKey(key).addKeys(fields);
return createCommand(HDEL, new IntegerOutput<>(codec), args);
Expand Down Expand Up @@ -1554,38 +1545,32 @@ Command<K, V, Long> hlen(K key) {
}

Command<K, V, List<V>> 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<K, V> args = new CommandArgs<>(codec).addKey(key).addKeys(fields);
return createCommand(HMGET, new ValueListOutput<>(codec), args);
}

Command<K, V, Long> hmget(ValueStreamingChannel<V> 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<K, V> args = new CommandArgs<>(codec).addKey(key).addKeys(fields);
return createCommand(HMGET, new ValueStreamingOutput<>(codec, channel), args);
}

Command<K, V, Long> hmget(KeyValueStreamingChannel<K, V> 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<K, V> args = new CommandArgs<>(codec).addKey(key).addKeys(fields);
return createCommand(HMGET, new KeyValueStreamingOutput<>(codec, channel, Arrays.asList(fields)), args);
}

Command<K, V, List<KeyValue<K, V>>> 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<K, V> args = new CommandArgs<>(codec).addKey(key).addKeys(fields);
return createCommand(HMGET, new KeyValueListOutput<>(codec, Arrays.asList(fields)), args);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ RedisFuture<StreamScanCursor> hscanNovalues(KeyStreamingChannel<K> 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<List<Long>> hpersist(K key, K... fields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ public interface RedisHashReactiveCommands<K, V> {
* @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<Long> hpersist(K key, K... fields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public interface RedisHashCommands<K, V> {
* @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<Long> hpersist(K key, K... fields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ AsyncExecutions<StreamScanCursor> hscanNovalues(KeyStreamingChannel<K> 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<List<Long>> hpersist(K key, K... fields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public interface NodeSelectionHashCommands<K, V> {
* @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<List<Long>> hpersist(K key, K... fields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ interface RedisHashCoroutinesCommands<K : Any, V : Any> {
* @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<Long>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ public interface RedisHashCommands<K, V> {
* @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<Long> hpersist(K key, K... fields);

Expand Down

0 comments on commit 9953306

Please sign in to comment.