K
- Key type.V
- Value type.public interface RedisJsonCommands<K,V>
Modifier and Type | Method and Description |
---|---|
List<Long> |
jsonArrappend(K key,
JsonPath jsonPath,
JsonValue... values)
Append the JSON values into the array at a given
JsonPath after the last element in a said array. |
List<Long> |
jsonArrappend(K key,
JsonPath jsonPath,
String... jsonStrings)
Append the JSON string values into the array at a given
JsonPath after the last element in a said array. |
List<Long> |
jsonArrappend(K key,
JsonValue... values)
Append the JSON values into the array at the
JsonPath.ROOT_PATH after the last element in a said array. |
List<Long> |
jsonArrappend(K key,
String... jsonStrings)
Append the JSON string values into the array at the
JsonPath.ROOT_PATH after the last element in a said array. |
List<Long> |
jsonArrindex(K key,
JsonPath jsonPath,
JsonValue value)
|
List<Long> |
jsonArrindex(K key,
JsonPath jsonPath,
JsonValue value,
JsonRangeArgs range)
|
List<Long> |
jsonArrindex(K key,
JsonPath jsonPath,
String jsonString)
Search for the first occurrence of a JSON string in an array at a given
JsonPath and return its index. |
List<Long> |
jsonArrindex(K key,
JsonPath jsonPath,
String jsonString,
JsonRangeArgs range)
Search for the first occurrence of a JSON string in an array at a given
JsonPath and return its index. |
List<Long> |
jsonArrinsert(K key,
JsonPath jsonPath,
int index,
JsonValue... values)
|
List<Long> |
jsonArrinsert(K key,
JsonPath jsonPath,
int index,
String... jsonStrings)
Insert the JSON string values into the array at a given
JsonPath before the provided index. |
List<Long> |
jsonArrlen(K key)
Report the length of the JSON array at a the
JsonPath.ROOT_PATH |
List<Long> |
jsonArrlen(K key,
JsonPath jsonPath)
Report the length of the JSON array at a given
JsonPath |
List<JsonValue> |
jsonArrpop(K key)
Remove and return
JsonValue at index -1 (last element) in the array at the JsonPath.ROOT_PATH |
List<JsonValue> |
jsonArrpop(K key,
JsonPath jsonPath)
|
List<JsonValue> |
jsonArrpop(K key,
JsonPath jsonPath,
int index)
|
List<Long> |
jsonArrtrim(K key,
JsonPath jsonPath,
JsonRangeArgs range)
Trim an array at a given
JsonPath so that it contains only the specified inclusive range of elements. |
Long |
jsonClear(K key)
Clear container values (arrays/objects) and set numeric values to 0 at the
JsonPath.ROOT_PATH |
Long |
jsonClear(K key,
JsonPath jsonPath)
Clear container values (arrays/objects) and set numeric values to 0
|
Long |
jsonDel(K key)
Deletes a value inside the JSON document at the
JsonPath.ROOT_PATH |
Long |
jsonDel(K key,
JsonPath jsonPath)
Deletes a value inside the JSON document at a given
JsonPath |
List<JsonValue> |
jsonGet(K key,
JsonGetArgs options,
JsonPath... jsonPaths)
Return the value at the specified path in JSON serialized form.
|
List<JsonValue> |
jsonGet(K key,
JsonPath... jsonPaths)
Return the value at the specified path in JSON serialized form.
|
String |
jsonMerge(K key,
JsonPath jsonPath,
JsonValue value)
|
String |
jsonMerge(K key,
JsonPath jsonPath,
String jsonString)
Merge a given JSON string with the value matching
JsonPath . |
List<JsonValue> |
jsonMGet(JsonPath jsonPath,
K... keys)
Return the values at the specified path from multiple key arguments.
|
String |
jsonMSet(List<JsonMsetArgs<K,V>> arguments)
Set or update one or more JSON values according to the specified
JsonMsetArgs
JSON.MSET is atomic, hence, all given additions or updates are either applied or not. |
List<Number> |
jsonNumincrby(K key,
JsonPath jsonPath,
Number number)
Increment the number value stored at the specified
JsonPath in the JSON document by the provided increment. |
List<V> |
jsonObjkeys(K key)
Return the keys in the JSON document that are referenced by the
JsonPath.ROOT_PATH |
List<V> |
jsonObjkeys(K key,
JsonPath jsonPath)
Return the keys in the JSON document that are referenced by the given
JsonPath |
List<Long> |
jsonObjlen(K key)
Report the number of keys in the JSON object at the
JsonPath.ROOT_PATH and for the provided key |
List<Long> |
jsonObjlen(K key,
JsonPath jsonPath)
Report the number of keys in the JSON object at the specified
JsonPath and for the provided key |
String |
jsonSet(K key,
JsonPath jsonPath,
JsonValue value)
Sets the JSON value at a given
JsonPath in the JSON document using defaults for the JsonSetArgs . |
String |
jsonSet(K key,
JsonPath jsonPath,
JsonValue value,
JsonSetArgs options)
Sets the JSON value at a given
JsonPath in the JSON document. |
String |
jsonSet(K key,
JsonPath jsonPath,
String jsonString)
Sets the JSON value at a given
JsonPath in the JSON document using defaults for the JsonSetArgs . |
String |
jsonSet(K key,
JsonPath jsonPath,
String jsonString,
JsonSetArgs options)
Sets the JSON value at a given
JsonPath in the JSON document. |
List<Long> |
jsonStrappend(K key,
JsonPath jsonPath,
JsonValue value)
Append the json-string values to the string at the provided
JsonPath in the JSON document. |
List<Long> |
jsonStrappend(K key,
JsonPath jsonPath,
String jsonString)
Append the JSON string to the string at the provided
JsonPath in the JSON document. |
List<Long> |
jsonStrappend(K key,
JsonValue value)
Append the json-string values to the string at the
JsonPath.ROOT_PATH in the JSON document. |
List<Long> |
jsonStrappend(K key,
String jsonString)
Append the JSON string to the string at the
JsonPath.ROOT_PATH in the JSON document. |
List<Long> |
jsonStrlen(K key)
Report the length of the JSON String at the
JsonPath.ROOT_PATH in the JSON document. |
List<Long> |
jsonStrlen(K key,
JsonPath jsonPath)
Report the length of the JSON String at the provided
JsonPath in the JSON document. |
List<Long> |
jsonToggle(K key,
JsonPath jsonPath)
Toggle a Boolean value stored at the provided
JsonPath in the JSON document. |
List<JsonType> |
jsonType(K key)
Report the type of JSON value at the
JsonPath.ROOT_PATH in the JSON document. |
List<JsonType> |
jsonType(K key,
JsonPath jsonPath)
Report the type of JSON value at the provided
JsonPath in the JSON document. |
List<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values)
JsonPath
after the last element in a said array.List<Long> jsonArrappend(K key, JsonValue... values)
JsonPath.ROOT_PATH
after the last element in a said array.key
- the key holding the JSON document.values
- one or more JsonValue
to be appended.List<Long> jsonArrappend(K key, String... jsonStrings)
JsonPath.ROOT_PATH
after the last element in a said array.key
- the key holding the JSON document.jsonStrings
- one or more JSON strings to be appended.List<Long> jsonArrappend(K key, JsonPath jsonPath, String... jsonStrings)
JsonPath
after the last element in a said array.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.jsonStrings
- one or more JSON strings to be appended.List<Long> jsonArrindex(K key, JsonPath jsonPath, JsonValue value, JsonRangeArgs range)
JsonValue
in an array at a given JsonPath
and return its index.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.value
- the JsonValue
to search for.range
- the JsonRangeArgs
to search within.List<Long> jsonArrindex(K key, JsonPath jsonPath, JsonValue value)
JsonValue
in an array at a given JsonPath
and return its index. This
method uses defaults for the start and end indexes, see JsonRangeArgs.DEFAULT_START_INDEX
and
JsonRangeArgs.DEFAULT_END_INDEX
.List<Long> jsonArrindex(K key, JsonPath jsonPath, String jsonString)
JsonPath
and return its index. This
method uses defaults for the start and end indexes, see JsonRangeArgs.DEFAULT_START_INDEX
and
JsonRangeArgs.DEFAULT_END_INDEX
.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.jsonString
- the JSON string to search for.List<Long> jsonArrindex(K key, JsonPath jsonPath, String jsonString, JsonRangeArgs range)
JsonPath
and return its index.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.jsonString
- the JSON string to search for.range
- the JsonRangeArgs
to search within.List<Long> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue... values)
JsonValue
s into the array at a given JsonPath
before the provided index, shifting the existing
elements to the rightkey
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.index
- the index before which the new elements will be inserted.values
- one or more JsonValue
s to be inserted.List<Long> jsonArrinsert(K key, JsonPath jsonPath, int index, String... jsonStrings)
JsonPath
before the provided index.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.index
- the index before which the new elements will be inserted.jsonStrings
- one or more JSON strings to be inserted.List<Long> jsonArrlen(K key, JsonPath jsonPath)
JsonPath
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.List<Long> jsonArrlen(K key)
JsonPath.ROOT_PATH
key
- the key holding the JSON document.List<JsonValue> jsonArrpop(K key, JsonPath jsonPath, int index)
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.index
- the index of the element to be removed. Default is -1, meaning the last element. Out-of-range indexes round
to their respective array ends. Popping an empty array returns null.List<JsonValue> jsonArrpop(K key, JsonPath jsonPath)
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.List<JsonValue> jsonArrpop(K key)
JsonValue
at index -1 (last element) in the array at the JsonPath.ROOT_PATH
key
- the key holding the JSON document.List<Long> jsonArrtrim(K key, JsonPath jsonPath, JsonRangeArgs range)
JsonPath
so that it contains only the specified inclusive range of elements. All
elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed.
Behavior as of RedisJSON v2.0:
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the array inside the document.range
- the JsonRangeArgs
to trim by.Long jsonClear(K key, JsonPath jsonPath)
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value to clear.Long jsonClear(K key)
JsonPath.ROOT_PATH
key
- the key holding the JSON document.Long jsonDel(K key, JsonPath jsonPath)
JsonPath
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value to clear.Long jsonDel(K key)
JsonPath.ROOT_PATH
key
- the key holding the JSON document.List<JsonValue> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths)
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.
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).
key
- the key holding the JSON document.options
- the JsonGetArgs
to use.jsonPaths
- the JsonPath
s to use to identify the values to get.List<JsonValue> jsonGet(K key, JsonPath... jsonPaths)
JsonGetArgs
.
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.
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).
key
- the key holding the JSON document.jsonPaths
- the JsonPath
s to use to identify the values to get.String jsonMerge(K key, JsonPath jsonPath, JsonValue value)
JsonValue
with the value matching JsonPath
. Consequently, JSON values at matching paths are
updated, deleted, or expanded with new children.
Merging is done according to the following rules per JSON value in the value argument while considering the corresponding original value if it exists:
This command complies with RFC7396 "Json Merge Patch"
String jsonMerge(K key, JsonPath jsonPath, String jsonString)
JsonPath
.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value to merge.jsonString
- the JSON string to merge.List<JsonValue> jsonMGet(JsonPath jsonPath, K... keys)
String jsonMSet(List<JsonMsetArgs<K,V>> arguments)
JsonMsetArgs
JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to see that some keys were updated while others are unchanged.
A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected.
arguments
- the JsonMsetArgs
specifying the values to change.List<Number> jsonNumincrby(K key, JsonPath jsonPath, Number number)
JsonPath
in the JSON document by the provided increment.List<V> jsonObjkeys(K key, JsonPath jsonPath)
JsonPath
List<V> jsonObjkeys(K key)
JsonPath.ROOT_PATH
key
- the key holding the JSON document.JsonPath
.List<Long> jsonObjlen(K key, JsonPath jsonPath)
JsonPath
and for the provided keykey
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) whose key(s) we want to countList<Long> jsonObjlen(K key)
JsonPath.ROOT_PATH
and for the provided keykey
- the key holding the JSON document.String jsonSet(K key, JsonPath jsonPath, JsonValue value, JsonSetArgs options)
JsonPath
in the JSON document.
For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is added with the JSON value.
Adds a key (with its respective value) to a JSON Object (in a RedisJSON data type key) only if it is the last child in the path, or it is the parent of a new child being added in the path. Optional arguments NX and XX modify this behavior for both new RedisJSON data type keys and the JSON Object keys in them.
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) where we want to set the value.value
- the JsonValue
to set.options
- the JsonSetArgs
the options for setting the value.JsonSetArgs
conditions are not met.String jsonSet(K key, JsonPath jsonPath, JsonValue value)
JsonPath
in the JSON document using defaults for the JsonSetArgs
.
For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is added with the JSON value.
Adds a key (with its respective value) to a JSON Object (in a RedisJSON data type key) only if it is the last child in the path, or it is the parent of a new child being added in the path. Optional arguments NX and XX modify this behavior for both new RedisJSON data type keys and the JSON Object keys in them.
key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) where we want to set the value.value
- the JsonValue
to set.JsonSetArgs
conditions are not met.String jsonSet(K key, JsonPath jsonPath, String jsonString)
JsonPath
in the JSON document using defaults for the JsonSetArgs
.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) where we want to set the value.jsonString
- the JSON string to set.JsonSetArgs
conditions are not met.String jsonSet(K key, JsonPath jsonPath, String jsonString, JsonSetArgs options)
JsonPath
in the JSON document.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) where we want to set the value.jsonString
- the JSON string to set.options
- the JsonSetArgs
the options for setting the value.JsonSetArgs
conditions are not met.List<Long> jsonStrappend(K key, JsonPath jsonPath, JsonValue value)
JsonPath
in the JSON document.List<Long> jsonStrappend(K key, JsonValue value)
JsonPath.ROOT_PATH
in the JSON document.key
- the key holding the JSON document.value
- the JsonValue
to append.List<Long> jsonStrappend(K key, String jsonString)
JsonPath.ROOT_PATH
in the JSON document.key
- the key holding the JSON document.jsonString
- the JSON string to append.List<Long> jsonStrappend(K key, JsonPath jsonPath, String jsonString)
JsonPath
in the JSON document.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s) where we want to append the value.jsonString
- the JSON string to append.List<Long> jsonStrlen(K key, JsonPath jsonPath)
JsonPath
in the JSON document.List<Long> jsonStrlen(K key)
JsonPath.ROOT_PATH
in the JSON document.key
- the key holding the JSON document.JsonPath
, or null if the value
ath the desired path is not a string.List<Long> jsonToggle(K key, JsonPath jsonPath)
JsonPath
in the JSON document.key
- the key holding the JSON document.jsonPath
- the JsonPath
pointing to the value(s).List<JsonType> jsonType(K key, JsonPath jsonPath)
JsonPath
in the JSON document.List<JsonType> jsonType(K key)
JsonPath.ROOT_PATH
in the JSON document.key
- the key holding the JSON document.JsonPath
Copyright © 2025 lettuce.io. All rights reserved.