Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,16 @@ public RedisFuture<List<String>> jsonGetRaw(K key, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGetRaw(key, JsonGetArgs.Builder.defaults(), jsonPaths));
}

@Override
public RedisFuture<String> jsonGetValueRaw(K key, JsonGetArgs options, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGetValueRaw(key, options, jsonPaths));
}

@Override
public RedisFuture<String> jsonGetValueRaw(K key, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGetValueRaw(key, JsonGetArgs.Builder.defaults(), jsonPaths));
}

@Override
public RedisFuture<Long> jsonDel(K key) {
return dispatch(jsonCommandBuilder.jsonDel(key, JsonPath.ROOT_PATH));
Expand All @@ -1909,6 +1919,16 @@ public RedisFuture<List<JsonValue>> jsonGet(K key, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGet(key, JsonGetArgs.Builder.defaults(), jsonPaths));
}

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

@Override
public RedisFuture<JsonValue> jsonGetValue(K key, JsonPath... jsonPaths) {
return dispatch(jsonCommandBuilder.jsonGetValue(key, JsonGetArgs.Builder.defaults(), jsonPaths));
}

@Override
public RedisFuture<String> jsonMerge(K key, JsonPath jsonPath, JsonValue value) {
return dispatch(jsonCommandBuilder.jsonMerge(key, jsonPath, value));
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,17 @@ public Flux<String> jsonGetRaw(K key, JsonPath... jsonPaths) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonGetRaw(key, args, jsonPaths));
}

@Override
public Mono<String> jsonGetValueRaw(K key, JsonGetArgs options, JsonPath... jsonPaths) {
return createMono(() -> jsonCommandBuilder.jsonGetValueRaw(key, options, jsonPaths));
}

@Override
public Mono<String> jsonGetValueRaw(K key, JsonPath... jsonPaths) {
final JsonGetArgs args = JsonGetArgs.Builder.defaults();
return createMono(() -> jsonCommandBuilder.jsonGetValueRaw(key, args, jsonPaths));
}

@Override
public Mono<Long> jsonDel(K key) {
return createMono(() -> jsonCommandBuilder.jsonDel(key, JsonPath.ROOT_PATH));
Expand All @@ -1970,6 +1981,17 @@ public Flux<JsonValue> jsonGet(K key, JsonPath... jsonPaths) {
return createDissolvingFlux(() -> jsonCommandBuilder.jsonGet(key, args, jsonPaths));
}

@Override
public Mono<JsonValue> jsonGetValue(K key, JsonGetArgs options, JsonPath... jsonPaths) {
return createMono(() -> jsonCommandBuilder.jsonGetValue(key, options, jsonPaths));
}

@Override
public Mono<JsonValue> jsonGetValue(K key, JsonPath... jsonPaths) {
final JsonGetArgs args = JsonGetArgs.Builder.defaults();
return createMono(() -> jsonCommandBuilder.jsonGetValue(key, args, jsonPaths));
}

@Override
public Mono<String> jsonMerge(K key, JsonPath jsonPath, JsonValue value) {
return createMono(() -> jsonCommandBuilder.jsonMerge(key, jsonPath, value));
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/io/lettuce/core/RedisJsonCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,28 @@ Command<K, V, List<JsonValue>> jsonGet(K key, JsonGetArgs options, JsonPath... j
return createCommand(JSON_GET, new JsonValueListOutput<>(codec, parser.get()), args);
}

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

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

if (options != null) {
// OPTIONAL as per API
options.build(args);
}

if (jsonPaths != null) {
// OPTIONAL as per API
for (JsonPath jsonPath : jsonPaths) {
if (jsonPath != null) {
args.add(jsonPath.toString());
}
}
}

return createCommand(JSON_GET, new JsonValueOutput<>(codec, parser.get()), args);
}

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

Expand All @@ -259,6 +281,28 @@ Command<K, V, List<String>> jsonGetRaw(K key, JsonGetArgs options, JsonPath... j
return createCommand(JSON_GET, new StringListOutput<>(codec), args);
}

Command<K, V, String> jsonGetValueRaw(K key, JsonGetArgs options, JsonPath... jsonPaths) {
notNullKey(key);

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

if (options != null) {
// OPTIONAL as per API
options.build(args);
}

if (jsonPaths != null) {
// OPTIONAL as per API
for (JsonPath jsonPath : jsonPaths) {
if (jsonPath != null) {
args.add(jsonPath.toString());
}
}
}

return createCommand(JSON_GET, new StatusOutput<>(codec), args);
}

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

notNullKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,32 @@ public interface RedisJsonAsyncCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 6.5
* @deprecated since 7.6, use {@link #jsonGetValue(Object, JsonGetArgs, JsonPath...)} instead. The {@code JSON.GET} command
* always returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
RedisFuture<List<JsonValue>> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form.
* <p>
* When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON
* value. In contrast, a legacy path returns a single value.
* <p>
* When using multiple JSONPath arguments, the root of the matching values is a JSON string with a top-level object, with
* each object value being a top-level array of serialized JSON value. In contrast, if all paths are legacy paths, each
* object value is a single serialized JSON value. If there are multiple paths that include both legacy path and JSONPath,
* the returned value conforms to the JSONPath version (an array of values).
*
* @param key the key holding the JSON document.
* @param options the {@link JsonGetArgs} to use.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
RedisFuture<JsonValue> jsonGetValue(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as raw strings.
* <p>
Expand All @@ -324,9 +347,27 @@ public interface RedisJsonAsyncCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return List<String> the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.0
* @deprecated since 7.6, use {@link #jsonGetValueRaw(Object, JsonGetArgs, JsonPath...)} instead. The {@code JSON.GET}
* command always returns a single bulk string reply regardless of the number of paths, so returning a
* {@code List} is misleading.
*/
@Deprecated
RedisFuture<List<String>> jsonGetRaw(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as a raw string.
* <p>
* Behaves like {@link #jsonGetValue(Object, JsonGetArgs, JsonPath...)} but returns {@code String} with raw JSON instead of
* {@link JsonValue} wrapper.
*
* @param key the key holding the JSON document.
* @param options the {@link JsonGetArgs} to use.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return String the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
RedisFuture<String> jsonGetValueRaw(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}.
* <p>
Expand All @@ -342,9 +383,31 @@ public interface RedisJsonAsyncCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 6.5
* @deprecated since 7.6, use {@link #jsonGetValue(Object, JsonPath...)} instead. The {@code JSON.GET} command always
* returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
RedisFuture<List<JsonValue>> jsonGet(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}.
* <p>
* When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON
* value. In contrast, a legacy path returns a single value.
* <p>
* When using multiple JSONPath arguments, the root of the matching values is a JSON string with a top-level object, with
* each object value being a top-level array of serialized JSON value. In contrast, if all paths are legacy paths, each
* object value is a single serialized JSON value. If there are multiple paths that include both legacy path and JSONPath,
* the returned value conforms to the JSONPath version (an array of values).
*
* @param key the key holding the JSON document.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
RedisFuture<JsonValue> jsonGetValue(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as raw strings. Uses defaults for the {@link JsonGetArgs}.
* <p>
Expand All @@ -355,9 +418,27 @@ public interface RedisJsonAsyncCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return List<String> the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.0
* @deprecated since 7.6, use {@link #jsonGetValueRaw(Object, JsonPath...)} instead. The {@code JSON.GET} command always
* returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
RedisFuture<List<String>> jsonGetRaw(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as a raw string. Uses defaults for the
* {@link JsonGetArgs}.
* <p>
* Behaves like {@link #jsonGetValue(Object, JsonPath...)} but returns {@code String} with raw JSON instead of
* {@link JsonValue} wrapper.
*
* @param key the key holding the JSON document.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return String the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
RedisFuture<String> jsonGetValueRaw(K key, JsonPath... jsonPaths);

/**
* Merge a given {@link JsonValue} with the value matching {@link JsonPath}. Consequently, JSON values at matching paths are
* updated, deleted, or expanded with new children.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,32 @@ public interface RedisJsonReactiveCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 6.5
* @deprecated since 7.6, use {@link #jsonGetValue(Object, JsonGetArgs, JsonPath...)} instead. The {@code JSON.GET} command
* always returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
Flux<JsonValue> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form.
* <p>
* When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON
* value. In contrast, a legacy path returns a single value.
* <p>
* When using multiple JSONPath arguments, the root of the matching values is a JSON string with a top-level object, with
* each object value being a top-level array of serialized JSON value. In contrast, if all paths are legacy paths, each
* object value is a single serialized JSON value. If there are multiple paths that include both legacy path and JSONPath,
* the returned value conforms to the JSONPath version (an array of values).
*
* @param key the key holding the JSON document.
* @param options the {@link JsonGetArgs} to use.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
Mono<JsonValue> jsonGetValue(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as raw strings.
* <p>
Expand All @@ -325,9 +348,27 @@ public interface RedisJsonReactiveCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return List<String> the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.0
* @deprecated since 7.6, use {@link #jsonGetValueRaw(Object, JsonGetArgs, JsonPath...)} instead. The {@code JSON.GET}
* command always returns a single bulk string reply regardless of the number of paths, so returning a
* {@code List} is misleading.
*/
@Deprecated
Flux<String> jsonGetRaw(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as a raw string.
* <p>
* Behaves like {@link #jsonGetValue(Object, JsonGetArgs, JsonPath...)} but returns {@code String} with raw JSON instead of
* {@link JsonValue} wrapper.
*
* @param key the key holding the JSON document.
* @param options the {@link JsonGetArgs} to use.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return String the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
Mono<String> jsonGetValueRaw(K key, JsonGetArgs options, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}.
* <p>
Expand All @@ -343,9 +384,31 @@ public interface RedisJsonReactiveCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 6.5
* @deprecated since 7.6, use {@link #jsonGetValue(Object, JsonPath...)} instead. The {@code JSON.GET} command always
* returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
Flux<JsonValue> jsonGet(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}.
* <p>
* When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON
* value. In contrast, a legacy path returns a single value.
* <p>
* When using multiple JSONPath arguments, the root of the matching values is a JSON string with a top-level object, with
* each object value being a top-level array of serialized JSON value. In contrast, if all paths are legacy paths, each
* object value is a single serialized JSON value. If there are multiple paths that include both legacy path and JSONPath,
* the returned value conforms to the JSONPath version (an array of values).
*
* @param key the key holding the JSON document.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return JsonValue the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
Mono<JsonValue> jsonGetValue(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as raw strings. Uses defaults for the {@link JsonGetArgs}.
* <p>
Expand All @@ -356,9 +419,27 @@ public interface RedisJsonReactiveCommands<K, V> {
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return List<String> the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.0
* @deprecated since 7.6, use {@link #jsonGetValueRaw(Object, JsonPath...)} instead. The {@code JSON.GET} command always
* returns a single bulk string reply regardless of the number of paths, so returning a {@code List} is
* misleading.
*/
@Deprecated
Flux<String> jsonGetRaw(K key, JsonPath... jsonPaths);

/**
* Return the value at the specified path in JSON serialized form as a raw string. Uses defaults for the
* {@link JsonGetArgs}.
* <p>
* Behaves like {@link #jsonGetValue(Object, JsonPath...)} but returns {@code String} with raw JSON instead of
* {@link JsonValue} wrapper.
*
* @param key the key holding the JSON document.
* @param jsonPaths the {@link JsonPath}s to use to identify the values to get.
* @return String the value at path in JSON serialized form, or null if the path does not exist.
* @since 7.6
*/
Mono<String> jsonGetValueRaw(K key, JsonPath... jsonPaths);

/**
* Merge a given {@link JsonValue} with the value matching {@link JsonPath}. Consequently, JSON values at matching paths are
* updated, deleted, or expanded with new children.
Expand Down
Loading
Loading