Skip to content

Commit

Permalink
No longer using K for the JSON object keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun committed Aug 28, 2024
1 parent 57390e8 commit 8314184
Show file tree
Hide file tree
Showing 34 changed files with 279 additions and 364 deletions.
20 changes: 10 additions & 10 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1463,17 +1463,17 @@ public boolean isOpen() {
}

@Override
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V>... values) {
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<V>... values) {
return dispatch(jsonCommandBuilder.jsonArrappend(key, jsonPath, values));
}

@Override
public RedisFuture<List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonRangeArgs range) {
public RedisFuture<List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<V> value, JsonRangeArgs range) {
return dispatch(jsonCommandBuilder.jsonArrindex(key, jsonPath, value, range));
}

@Override
public RedisFuture<List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<K, V>... values) {
public RedisFuture<List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<V>... values) {
return dispatch(jsonCommandBuilder.jsonArrinsert(key, jsonPath, index, values));
}

Expand All @@ -1483,7 +1483,7 @@ public RedisFuture<List<Long>> jsonArrlen(K key, JsonPath jsonPath) {
}

@Override
public RedisFuture<List<JsonValue<K, V>>> jsonArrpop(K key, JsonPath jsonPath, int index) {
public RedisFuture<List<JsonValue<V>>> jsonArrpop(K key, JsonPath jsonPath, int index) {
return dispatch(jsonCommandBuilder.jsonArrpop(key, jsonPath, index));
}

Expand All @@ -1503,17 +1503,17 @@ public RedisFuture<Long> jsonDel(K key, JsonPath jsonPath) {
}

@Override
public RedisFuture<List<JsonValue<K, V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
public RedisFuture<List<JsonValue<V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGet(key, options, jsonPaths));
}

@Override
public RedisFuture<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<K, V> value) {
public RedisFuture<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<V> value) {
return dispatch(jsonCommandBuilder.jsonMerge(key, jsonPath, value));
}

@Override
public RedisFuture<List<JsonValue<K, V>>> jsonMGet(JsonPath jsonPath, K... keys) {
public RedisFuture<List<JsonValue<V>>> jsonMGet(JsonPath jsonPath, K... keys) {
return dispatch(jsonCommandBuilder.jsonMGet(jsonPath, keys));
}

Expand All @@ -1528,7 +1528,7 @@ public RedisFuture<List<Number>> jsonNumincrby(K key, JsonPath jsonPath, Number
}

@Override
public RedisFuture<List<K>> jsonObjkeys(K key, JsonPath jsonPath) {
public RedisFuture<List<V>> jsonObjkeys(K key, JsonPath jsonPath) {
return dispatch(jsonCommandBuilder.jsonObjkeys(key, jsonPath));
}

Expand All @@ -1538,12 +1538,12 @@ public RedisFuture<List<Long>> jsonObjlen(K key, JsonPath jsonPath) {
}

@Override
public RedisFuture<String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonSetArgs options) {
public RedisFuture<String> jsonSet(K key, JsonPath jsonPath, JsonValue<V> value, JsonSetArgs options) {
return dispatch(jsonCommandBuilder.jsonSet(key, jsonPath, value, options));
}

@Override
public RedisFuture<List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<K, V> value) {
public RedisFuture<List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<V> value) {
return dispatch(jsonCommandBuilder.jsonStrappend(key, jsonPath, value));
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1526,17 +1526,17 @@ public boolean isOpen() {
}

@Override
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V>... values) {
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue<V>... values) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrappend(key, jsonPath, values));
}

@Override
public Flux<Long> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonRangeArgs range) {
public Flux<Long> jsonArrindex(K key, JsonPath jsonPath, JsonValue<V> value, JsonRangeArgs range) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrindex(key, jsonPath, value, range));
}

@Override
public Flux<Long> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<K, V>... values) {
public Flux<Long> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<V>... values) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrinsert(key, jsonPath, index, values));
}

Expand All @@ -1546,7 +1546,7 @@ public Flux<Long> jsonArrlen(K key, JsonPath jsonPath) {
}

@Override
public Flux<JsonValue<K, V>> jsonArrpop(K key, JsonPath jsonPath, int index) {
public Flux<JsonValue<V>> jsonArrpop(K key, JsonPath jsonPath, int index) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrpop(key, jsonPath, index));
}

Expand All @@ -1566,17 +1566,17 @@ public Mono<Long> jsonDel(K key, JsonPath jsonPath) {
}

@Override
public Flux<JsonValue<K, V>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
public Flux<JsonValue<V>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonGet(key, options, jsonPaths));
}

@Override
public Mono<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<K, V> value) {
public Mono<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<V> value) {
return createMono(() -> jsonCommandBuilder.jsonMerge(key, jsonPath, value));
}

@Override
public Flux<JsonValue<K, V>> jsonMGet(JsonPath jsonPath, K... keys) {
public Flux<JsonValue<V>> jsonMGet(JsonPath jsonPath, K... keys) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonMGet(jsonPath, keys));
}

Expand All @@ -1591,7 +1591,7 @@ public Flux<Number> jsonNumincrby(K key, JsonPath jsonPath, Number number) {
}

@Override
public Flux<K> jsonObjkeys(K key, JsonPath jsonPath) {
public Flux<V> jsonObjkeys(K key, JsonPath jsonPath) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonObjkeys(key, jsonPath));
}

Expand All @@ -1601,12 +1601,12 @@ public Flux<Long> jsonObjlen(K key, JsonPath jsonPath) {
}

@Override
public Mono<String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonSetArgs options) {
public Mono<String> jsonSet(K key, JsonPath jsonPath, JsonValue<V> value, JsonSetArgs options) {
return createMono(() -> jsonCommandBuilder.jsonSet(key, jsonPath, value, options));
}

@Override
public Flux<Long> jsonStrappend(K key, JsonPath jsonPath, JsonValue<K, V> value) {
public Flux<Long> jsonStrappend(K key, JsonPath jsonPath, JsonValue<V> value) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonStrappend(key, jsonPath, value));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/RedisAsyncCommandsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public StatefulRedisConnection<K, V> getStatefulConnection() {
}

@Override
public JsonParser<K, V> getJsonParser() {
public JsonParser<V> getJsonParser() {
return JsonParserRegistry.getJsonParser(this.codec);
}

@Override
public void setJsonParser(JsonParser<K, V> jsonParser) {
public void setJsonParser(JsonParser<V> jsonParser) {
throw new UnsupportedOperationException("Setting a custom JsonParser is not supported");
}

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/io/lettuce/core/RedisJsonCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RedisJsonCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
super(codec);
}

Command<K, V, List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V>... jsonValues) {
Command<K, V, List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<V>... jsonValues) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -44,14 +44,14 @@ Command<K, V, List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V
args.add(jsonPath.toString());
}

for (JsonValue<K, V> value : jsonValues) {
for (JsonValue<V> value : jsonValues) {
args.add(value.asByteBuffer().array());
}

return createCommand(JSON_ARRAPPEND, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonRangeArgs range) {
Command<K, V, List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<V> value, JsonRangeArgs range) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -70,7 +70,7 @@ Command<K, V, List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V>
return createCommand(JSON_ARRINDEX, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<K, V>... values) {
Command<K, V, List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<V>... values) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -81,7 +81,7 @@ Command<K, V, List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, Jso

args.add(index);

for (JsonValue<K, V> value : values) {
for (JsonValue<V> value : values) {
args.add(value.asByteBuffer().array());
}

Expand All @@ -99,7 +99,7 @@ Command<K, V, List<Long>> jsonArrlen(K key, JsonPath jsonPath) {
return createCommand(JSON_ARRLEN, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<JsonValue<K, V>>> jsonArrpop(K key, JsonPath jsonPath, int index) {
Command<K, V, List<JsonValue<V>>> jsonArrpop(K key, JsonPath jsonPath, int index) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand Down Expand Up @@ -144,7 +144,7 @@ Command<K, V, Long> jsonClear(K key, JsonPath jsonPath) {
return createCommand(JSON_CLEAR, new IntegerOutput<>(codec), args);
}

Command<K, V, List<JsonValue<K, V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
Command<K, V, List<JsonValue<V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -164,7 +164,7 @@ Command<K, V, List<JsonValue<K, V>>> jsonGet(K key, JsonGetArgs options, JsonPat
return createCommand(JSON_GET, new JsonValueListOutput<>(codec), args);
}

Command<K, V, String> jsonMerge(K key, JsonPath jsonPath, JsonValue<K, V> value) {
Command<K, V, String> jsonMerge(K key, JsonPath jsonPath, JsonValue<V> value) {

notNullKey(key);

Expand All @@ -179,7 +179,7 @@ Command<K, V, String> jsonMerge(K key, JsonPath jsonPath, JsonValue<K, V> value)
return createCommand(JSON_MERGE, new StatusOutput<>(codec), args);
}

Command<K, V, List<JsonValue<K, V>>> jsonMGet(JsonPath jsonPath, K... keys) {
Command<K, V, List<JsonValue<V>>> jsonMGet(JsonPath jsonPath, K... keys) {
notEmpty(keys);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKeys(keys);
Expand Down Expand Up @@ -218,7 +218,7 @@ Command<K, V, List<Number>> jsonNumincrby(K key, JsonPath jsonPath, Number numbe
return createCommand(JSON_NUMINCRBY, new NumberListOutput<>(codec), args);
}

Command<K, V, List<K>> jsonObjkeys(K key, JsonPath jsonPath) {
Command<K, V, List<V>> jsonObjkeys(K key, JsonPath jsonPath) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -227,7 +227,7 @@ Command<K, V, List<K>> jsonObjkeys(K key, JsonPath jsonPath) {
args.add(jsonPath.toString());
}

return createCommand(JSON_OBJKEYS, new KeyListOutput<>(codec), args);
return createCommand(JSON_OBJKEYS, new ValueListOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonObjlen(K key, JsonPath jsonPath) {
Expand All @@ -243,7 +243,7 @@ Command<K, V, List<Long>> jsonObjlen(K key, JsonPath jsonPath) {
return createCommand(JSON_OBJLEN, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonSetArgs options) {
Command<K, V, String> jsonSet(K key, JsonPath jsonPath, JsonValue<V> value, JsonSetArgs options) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand All @@ -259,7 +259,7 @@ Command<K, V, String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, J
return createCommand(JSON_SET, new StatusOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<K, V> value) {
Command<K, V, List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<V> value) {
notNullKey(key);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/RedisReactiveCommandsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public StatefulRedisConnection<K, V> getStatefulConnection() {
}

@Override
public JsonParser<K, V> getJsonParser() {
public JsonParser<V> getJsonParser() {
return JsonParserRegistry.getJsonParser(this.codec);
}

@Override
public void setJsonParser(JsonParser<K, V> jsonParser) {
public void setJsonParser(JsonParser<V> jsonParser) {
throw new UnsupportedOperationException("Setting a custom JsonParser is not supported");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public interface RedisAsyncCommands<K, V> extends BaseRedisAsyncCommands<K, V>,
@Deprecated
StatefulRedisConnection<K, V> getStatefulConnection();

JsonParser<K, V> getJsonParser();
JsonParser<V> getJsonParser();

void setJsonParser(JsonParser<K, V> jsonParser);
void setJsonParser(JsonParser<V> jsonParser);

}
20 changes: 10 additions & 10 deletions src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return Long the resulting size of the arrays after the new data was appended, or null if the path does not exist.
* @since 6.5
*/
RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V>... values);
RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<V>... values);

/**
* Search for the first occurrence of a {@link JsonValue} in an array at a given {@link JsonPath} and return its index.
Expand All @@ -48,7 +48,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return Long the index hosting the searched element, -1 if not found or null if the specified path is not an array.
* @since 6.5
*/
RedisFuture<List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonRangeArgs range);
RedisFuture<List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<V> value, JsonRangeArgs range);

/**
* Insert the {@link JsonValue}s into the array at a given {@link JsonPath} before the provided index, shifting the existing
Expand All @@ -61,7 +61,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return Long the resulting size of the arrays after the new data was inserted, or null if the path does not exist.
* @since 6.5
*/
RedisFuture<List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<K, V>... values);
RedisFuture<List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<V>... values);

/**
* Report the length of the JSON array at a given {@link JsonPath}
Expand All @@ -83,7 +83,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return List<JsonValue> the removed element, or null if the specified path is not an array.
* @since 6.5
*/
RedisFuture<List<JsonValue<K, V>>> jsonArrpop(K key, JsonPath jsonPath, int index);
RedisFuture<List<JsonValue<V>>> jsonArrpop(K key, JsonPath jsonPath, int index);

/**
* Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All
Expand Down Expand Up @@ -141,7 +141,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 6.5
*/
RedisFuture<List<JsonValue<K, V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths);
RedisFuture<List<JsonValue<V>>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Merge a given {@link JsonValue} with the value matching {@link JsonPath}. Consequently, JSON values at matching paths are
Expand All @@ -165,7 +165,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @since 6.5
* @see <A href="https://tools.ietf.org/html/rfc7396">RFC7396</a>
*/
RedisFuture<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<K, V> value);
RedisFuture<String> jsonMerge(K key, JsonPath jsonPath, JsonValue<V> value);

/**
* Return the values at path from multiple key arguments.
Expand All @@ -175,7 +175,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return List<JsonValue> the values at path, or null if the path does not exist.
* @since 6.5
*/
RedisFuture<List<JsonValue<K, V>>> jsonMGet(JsonPath jsonPath, K... keys);
RedisFuture<List<JsonValue<V>>> jsonMGet(JsonPath jsonPath, K... keys);

/**
* Set or update one or more JSON values according to the specified {@link JsonMsetArgs}
Expand Down Expand Up @@ -210,7 +210,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return List<K> the keys in the JSON document that are referenced by the given {@link JsonPath}.
* @since 6.5
*/
RedisFuture<List<K>> jsonObjkeys(K key, JsonPath jsonPath);
RedisFuture<List<V>> jsonObjkeys(K key, JsonPath jsonPath);

/**
* Report the number of keys in the JSON object at path in key
Expand Down Expand Up @@ -240,7 +240,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return String "OK" if the set was successful, null if the {@link JsonSetArgs} conditions are not met.
* @since 6.5
*/
RedisFuture<String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonSetArgs options);
RedisFuture<String> jsonSet(K key, JsonPath jsonPath, JsonValue<V> value, JsonSetArgs options);

/**
* Append the json-string values to the string at the provided {@link JsonPath} in the JSON document.
Expand All @@ -251,7 +251,7 @@ public interface RedisJsonAsyncCommands<K, V> {
* @return Long the new length of the string, or null if the matching JSON value is not a string.
* @since 6.5
*/
RedisFuture<List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<K, V> value);
RedisFuture<List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<V> value);

/**
* Report the length of the JSON String at the provided {@link JsonPath} in the JSON document.
Expand Down
Loading

0 comments on commit 8314184

Please sign in to comment.