Package io.quarkus.redis.datasource.json
Interface JsonCommands<K>
-
- Type Parameters:
K- the type of the key
- All Superinterfaces:
RedisCommands
- All Known Implementing Classes:
BlockingJsonCommandsImpl
public interface JsonCommands<K> extends RedisCommands
Allows executing commands from thejsongroup (requires the Redis stack). See the json command list for further information about these commands.Redis JSON lets you store, update, and retrieve JSON values in a Redis database, similar to any other Redis data type.
Ths API is based on the
JsonObjectandJsonArraytypes. Some methods also allows direct mapping from and to objects. In the case of deserialization, theClassmust be passed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> List<Integer>jsonArrAppend(K key, String path, T... values)Execute the command JSON.ARRAPPEND.default <T> List<Integer>jsonArrIndex(K key, String path, T value)Execute the command JSON.ARRINDEX.<T> List<Integer>jsonArrIndex(K key, String path, T value, int start, int end)Execute the command JSON.ARRINDEX.<T> List<Integer>jsonArrInsert(K key, String path, int index, T... values)Execute the command JSON.ARRINSERT.default OptionalIntjsonArrLen(K key)Execute the command JSON.ARRLEN.List<Integer>jsonArrLen(K key, String path)Execute the command JSON.ARRLEN.default <T> TjsonArrPop(K key, Class<T> clazz)Execute the command JSON.ARRPOP.default <T> List<T>jsonArrPop(K key, Class<T> clazz, String path)Execute the command JSON.ARRPOP.<T> List<T>jsonArrPop(K key, Class<T> clazz, String path, int index)Execute the command JSON.ARRPOP.List<Integer>jsonArrTrim(K key, String path, int start, int stop)Execute the command JSON.ARRTRIM.default intjsonClear(K key)Execute the command JSON.CLEAR.intjsonClear(K key, String path)Execute the command JSON.CLEAR.default intjsonDel(K key)Execute the command JSON.DEL.intjsonDel(K key, String path)Execute the command JSON.DEL.<T> TjsonGet(K key, Class<T> clazz)Execute the command JSON.GET.io.vertx.core.json.JsonArrayjsonGet(K key, String path)Execute the command JSON.GET.io.vertx.core.json.JsonObjectjsonGet(K key, String... paths)Execute the command JSON.GET.io.vertx.core.json.JsonArrayjsonGetArray(K key)Execute the command JSON.GET.io.vertx.core.json.JsonObjectjsonGetObject(K key)Execute the command JSON.GET.List<io.vertx.core.json.JsonArray>jsonMget(String path, K... keys)Execute the command JSON.MGET.voidjsonNumincrby(K key, String path, double value)Execute the command JSON.NUMINCRBY.default List<String>jsonObjKeys(K key)Execute the command JSON.OBJKEYS.List<List<String>>jsonObjKeys(K key, String path)Execute the command JSON.OBJKEYS.default OptionalIntjsonObjLen(K key)Execute the command JSON.OBJLEN.List<Integer>jsonObjLen(K key, String path)Execute the command JSON.OBJLEN.default voidjsonSet(K key, io.vertx.core.json.JsonArray json)Execute the command JSON.SET.default voidjsonSet(K key, io.vertx.core.json.JsonObject json)Execute the command JSON.SET.voidjsonSet(K key, String path, io.vertx.core.json.JsonArray json)Execute the command JSON.SET.voidjsonSet(K key, String path, io.vertx.core.json.JsonArray json, JsonSetArgs args)Execute the command JSON.SET.voidjsonSet(K key, String path, io.vertx.core.json.JsonObject json)Execute the command JSON.SET.voidjsonSet(K key, String path, io.vertx.core.json.JsonObject json, JsonSetArgs args)Execute the command JSON.SET.<T> voidjsonSet(K key, String path, T value)Execute the command JSON.SET.<T> voidjsonSet(K key, String path, T value, JsonSetArgs args)Execute the command JSON.SET.default <T> voidjsonSet(K key, T value)Execute the command JSON.SET.List<Integer>jsonStrAppend(K key, String path, String value)Execute the command JSON.STRAPPEND.List<Integer>jsonStrLen(K key, String path)Execute the command JSON.STRLEN.List<Boolean>jsonToggle(K key, String path)Execute the command JSON.TOGGLE.List<String>jsonType(K key, String path)Execute the command JSON.TYPE.-
Methods inherited from interface io.quarkus.redis.datasource.RedisCommands
getDataSource
-
-
-
-
Method Detail
-
jsonSet
<T> void jsonSet(K key, String path, T value)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Type Parameters:
T- the type for the value- Parameters:
key- the key, must not benullpath- the path, must not benullvalue- the value, encoded to JSON
-
jsonSet
default <T> void jsonSet(K key, T value)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Type Parameters:
T- the type for the value- Parameters:
key- the key, must not benullvalue- the value, encoded to JSON
-
jsonSet
void jsonSet(K key, String path, io.vertx.core.json.JsonObject json)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benulljson- the JSON object to store, must not benull
-
jsonSet
default void jsonSet(K key, io.vertx.core.json.JsonObject json)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: jsonThis variant uses
$as path.- Parameters:
key- the key, must not benulljson- the JSON object to store, must not benull
-
jsonSet
void jsonSet(K key, String path, io.vertx.core.json.JsonObject json, JsonSetArgs args)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benulljson- the JSON object to store, must not benullargs- the extra arguments
-
jsonSet
void jsonSet(K key, String path, io.vertx.core.json.JsonArray json)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benulljson- the JSON array to store, must not benull
-
jsonSet
default void jsonSet(K key, io.vertx.core.json.JsonArray json)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benulljson- the JSON array to store, must not benull
-
jsonSet
void jsonSet(K key, String path, io.vertx.core.json.JsonArray json, JsonSetArgs args)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benulljson- the JSON array to store, must not benullargs- the extra arguments
-
jsonSet
<T> void jsonSet(K key, String path, T value, JsonSetArgs args)
Execute the command JSON.SET. Summary: Sets the JSON value at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benullvalue- the value to store, encoded to JSON.args- the extra arguments
-
jsonGet
<T> T jsonGet(K key, Class<T> clazz)
Execute the command JSON.GET. Summary: Returns the value at path in JSON serialized form. Group: jsonThis method uses the root path (
$). It map the retrieve JSON document to an object of type<T>.- Parameters:
key- the key, must not benullclazz- the type of object to recreate from the JSON content- Returns:
- the object,
nullif it does not exist
-
jsonGetObject
io.vertx.core.json.JsonObject jsonGetObject(K key)
Execute the command JSON.GET. Summary: Returns the value at path in JSON serialized form. Group: jsonThis method uses the root path (
$). UnlikejsonGet(Object, Class), it returns aJsonObject.- Parameters:
key- the key, must not benull- Returns:
- the stored JSON object,
nullif it does not exist
-
jsonGetArray
io.vertx.core.json.JsonArray jsonGetArray(K key)
Execute the command JSON.GET. Summary: Returns the value at path in JSON serialized form. Group: jsonThis method uses the root path (
$). UnlikejsonGet(Object, Class), it returns aJsonArray.- Parameters:
key- the key, must not benull- Returns:
- the stored JSON array,
nullif it does not exist
-
jsonGet
io.vertx.core.json.JsonArray jsonGet(K key, String path)
Execute the command JSON.GET. Summary: Returns the value at path in JSON serialized form. Group: json- Parameters:
key- the key, must not benullpath- the path, must not benull- Returns:
- the JSON array containing the different results,
nullif it does not exist.
-
jsonGet
io.vertx.core.json.JsonObject jsonGet(K key, String... paths)
Execute the command JSON.GET. Summary: Returns the value at path in JSON serialized form. Group: json- Parameters:
key- the key, must not benullpaths- the paths, must not benull. If no path are passed, this is equivalent tojsonGetObject(Object), if multiple paths are passed, the produced JSON object contains the result (as a json array) for each path.- Returns:
- the stored JSON object,
nullif it does not exist. If no path are passed, this is equivalent tojsonGetObject(Object). If multiple paths are passed, the produced JSON object contains the result for each pass as a JSON array.
-
jsonArrAppend
<T> List<Integer> jsonArrAppend(K key, String path, T... values)
Execute the command JSON.ARRAPPEND. Summary: Append the json values into the array at path after the last element in it. Group: json- Type Parameters:
T- the type of value- Parameters:
key- the key, must not benullpath- the path, must not benullvalues- the values to append, encoded to JSON- Returns:
- a list with the new sizes of each modified array (in order) or
null(instead of the size) if the point object was not an array.
-
jsonArrIndex
<T> List<Integer> jsonArrIndex(K key, String path, T value, int start, int end)
Execute the command JSON.ARRINDEX. Summary: Searches for the first occurrence of a scalar JSON value in an array. Group: json- Type Parameters:
T- the type of value- Parameters:
key- the key, must not benullpath- the path, must not benullvalue- the value to be searched, encoded to JSONstart- the start indexend- the end index- Returns:
- a list with the first position in the array of each JSON value that matches the path,
-1if not found in the array, ornullif the matching JSON value is not an array.
-
jsonArrIndex
default <T> List<Integer> jsonArrIndex(K key, String path, T value)
Execute the command JSON.ARRINDEX. Summary: Searches for the first occurrence of a scalar JSON value in an array. Group: json- Type Parameters:
T- the type of value- Parameters:
key- the key, must not benullpath- the path, must not benullvalue- the value to be searched, encoded to JSON- Returns:
- a list with the first position in the array of each JSON value that matches the path,
-1if not found in the array, ornullif the matching JSON value is not an array.
-
jsonArrInsert
<T> List<Integer> jsonArrInsert(K key, String path, int index, T... values)
Execute the command JSON.ARRINSERT. Summary: Inserts the json values into the array at path before the index (shifts to the right). Group: json- Type Parameters:
T- the type of value- Parameters:
key- the key, must not benullpath- the path, must not benullindex- the index. The index must be in the array's range. Inserting at index 0 prepends to the array. Negative index values start from the end of the array.values- the values to insert, encoded to JSON- Returns:
- a list of integer containing for each path, the array's new size or
nullif the matching JSON value is not an array.
-
jsonArrLen
List<Integer> jsonArrLen(K key, String path)
Execute the command JSON.ARRLEN. Summary: Reports the length of the JSON Array at path in key. Group: json- Parameters:
key- the key, must not benullpath- the path,nullmeans$- Returns:
- a list of integer containing for each path, the array's length, or @{code null} if the matching JSON value is not an array.
-
jsonArrLen
default OptionalInt jsonArrLen(K key)
Execute the command JSON.ARRLEN. Summary: Reports the length of the JSON Array at path in key. Group: json- Parameters:
key- the key, must not benull- Returns:
- an optional containing the array's length, empty if the matching JSON value is not an array.
-
jsonArrPop
<T> List<T> jsonArrPop(K key, Class<T> clazz, String path, int index)
Execute the command JSON.ARRPOP. Summary: Removes and returns an element from the index in the array. Group: json- Parameters:
key- the key, must not benullclazz- the type of the popped objectpath- path the path, defaults to root if not provided.index- is the position in the array to start popping from (defaults to -1, meaning the last element). Out-of-range indexes round to their respective array ends.- Returns:
- a list of T including for each path, an instance of T rebuilt from the JSON value, or
nullif the matching JSON value is not an array. Popping an empty array producesnull.
-
jsonArrPop
default <T> List<T> jsonArrPop(K key, Class<T> clazz, String path)
Execute the command JSON.ARRPOP. Summary: Removes and returns an element from the index in the array. Group: json- Parameters:
key- the key, must not benullclazz- the type of the popped objectpath- path the path, defaults to root if not provided.- Returns:
- a list of T including for each path, an instance of T rebuilt from the JSON value, or
nullif the matching JSON value is not an array. Popping an empty array producesnull.
-
jsonArrPop
default <T> T jsonArrPop(K key, Class<T> clazz)
Execute the command JSON.ARRPOP. Summary: Removes and returns an element from the index in the array. Group: jsonThis variant popped from the root object (must be a JSON array), and returns a single item.
- Parameters:
key- the key, must not benullclazz- the type of the popped object- Returns:
- an instance of T.
-
jsonArrTrim
List<Integer> jsonArrTrim(K key, String path, int start, int stop)
Execute the command JSON.ARRTRIM. Summary: Trims an array so that it contains only the specified inclusive range of elements. Group: json- Parameters:
key- the key, must not benullpath- path the path, must not benullstart- the start indexstop- the stop index- Returns:
- a list of integer containing, for each path, the array's new size, or
nullif the matching JSON value is not an array.
-
jsonClear
int jsonClear(K key, String path)
Execute the command JSON.CLEAR. Summary: Clears container values (Arrays/Objects), and sets numeric values to 0. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided. Non-existing paths are ignored.- Returns:
- the number of value cleared
-
jsonClear
default int jsonClear(K key)
Execute the command JSON.CLEAR. Summary: Clears container values (Arrays/Objects), and sets numeric values to 0. Group: json- Parameters:
key- the key, must not benull- Returns:
- the number of value cleared
-
jsonDel
int jsonDel(K key, String path)
Execute the command JSON.DEL. Summary: Deletes a value. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided. Non-existing paths are ignored.- Returns:
- the number of path deleted
-
jsonDel
default int jsonDel(K key)
Execute the command JSON.DEL. Summary: Deletes a value. Group: json- Parameters:
key- the key, must not benull- Returns:
- the number of path deleted (0 or more)
-
jsonMget
List<io.vertx.core.json.JsonArray> jsonMget(String path, K... keys)
Execute the command JSON.MGET. Summary: Returns the values at path from multiple key arguments. Returnsnullfor nonexistent keys and nonexistent paths. Group: json- Parameters:
path- path the pathkeys- the keys, must not benull, must not containnull- Returns:
- a list of JsonArray containing each retrieved value
-
jsonNumincrby
void jsonNumincrby(K key, String path, double value)
Execute the command JSON.NUMINCRBY. Summary: Increments the number value stored at path by number. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided. Non-existing paths are ignored.value- the value to add
-
jsonObjKeys
List<List<String>> jsonObjKeys(K key, String path)
Execute the command JSON.OBJKEYS. Summary: Returns the keys in the object that's referenced by path. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided.- Returns:
- a list containing, for each matching path, the list of keys, or
nullif the matching JSON value is not an object.
-
jsonObjKeys
default List<String> jsonObjKeys(K key)
Execute the command JSON.OBJKEYS. Summary: Returns the keys in the object that's referenced by path. Group: json- Parameters:
key- the key, must not benull- Returns:
- a list containing the list of keys, or
nullif the stored value is not a JSON object.
-
jsonObjLen
List<Integer> jsonObjLen(K key, String path)
Execute the command JSON.OBJLEN. Summary: Reports the number of keys in the JSON Object at path in key. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided.- Returns:
- a list containing, for each path, the length of the object,
nullif the matching JSON value is not an object
-
jsonObjLen
default OptionalInt jsonObjLen(K key)
Execute the command JSON.OBJLEN. Summary: Reports the number of keys in the JSON Object at path in key. Group: json- Parameters:
key- the key, must not benull- Returns:
- the length of the JSON object,
nullif the matching JSON value is not an object
-
jsonStrAppend
List<Integer> jsonStrAppend(K key, String path, String value)
Execute the command JSON.STRAPPEND. Summary: Appends the json-string values to the string at path. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided.value- the string to append, must not benull- Returns:
- a list containing, for each path, the new string length,
nullif the matching JSON value is not a string.
-
jsonStrLen
List<Integer> jsonStrLen(K key, String path)
Execute the command JSON.STRLEN. Summary: Reports the length of the JSON String at path in key. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided.- Returns:
- a list containing, for each path, the length of the string,
nullif the matching JSON value is not a string. Returnsnullif the key or path do not exist.
-
jsonToggle
List<Boolean> jsonToggle(K key, String path)
Execute the command JSON.TOGGLE. Summary: Toggle a boolean value stored at path. Group: json- Parameters:
key- the key, must not benullpath- path the path, must not benull- Returns:
- a list containing, for each path, the new boolean value,
nullif the matching JSON value is not a boolean.
-
jsonType
List<String> jsonType(K key, String path)
Execute the command JSON.TYPE. Summary: Reports the type of JSON value at path. Group: json- Parameters:
key- the key, must not benullpath- path the path, path defaults to$if not provided.- Returns:
- a list containing, for each path, the json type as String (string, integer, number, boolean, object, array), empty if no match.
-
-