Trait rustis::commands::JsonCommands

source ·
pub trait JsonCommands<'a> {
Show 22 methods // Provided methods fn json_arrappend<K, P, V, VV, R>( self, key: K, path: P, values: VV ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, VV: SingleArgCollection<V>, R: CollectionResponse<Option<usize>> { ... } fn json_arrindex<K, P, V, R>( self, key: K, path: P, value: V, options: JsonArrIndexOptions ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: CollectionResponse<Option<isize>> { ... } fn json_arrinsert<K, P, V, VV, R>( self, key: K, path: P, index: isize, values: VV ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, VV: SingleArgCollection<V>, R: CollectionResponse<Option<usize>> { ... } fn json_arrlen<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_arrpop<K, P, R, RR>( self, key: K, path: P, index: isize ) -> PreparedCommand<'a, Self, RR> where Self: Sized, K: SingleArg, P: SingleArg, R: PrimitiveResponse + DeserializeOwned, RR: CollectionResponse<R> { ... } fn json_arrtrim<K, P, R>( self, key: K, path: P, start: isize, stop: isize ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_clear<K, P>( self, key: K, path: P ) -> PreparedCommand<'a, Self, usize> where Self: Sized, K: SingleArg, P: SingleArg { ... } fn json_debug_memory<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<usize> { ... } fn json_del<K, P>(self, key: K, path: P) -> PreparedCommand<'a, Self, usize> where Self: Sized, K: SingleArg, P: SingleArg { ... } fn json_forget<K, P>( self, key: K, path: P ) -> PreparedCommand<'a, Self, usize> where Self: Sized, K: SingleArg, P: SingleArg { ... } fn json_get<K, V>( self, key: K, options: JsonGetOptions ) -> PreparedCommand<'a, Self, V> where Self: Sized, K: SingleArg, V: PrimitiveResponse { ... } fn json_mget<K, KK, P, V, VV>( self, keys: KK, path: P ) -> PreparedCommand<'a, Self, VV> where Self: Sized, K: SingleArg, KK: SingleArgCollection<K>, P: SingleArg, V: PrimitiveResponse + DeserializeOwned, VV: CollectionResponse<V> { ... } fn json_numincrby<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: PrimitiveResponse { ... } fn json_nummultby<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: PrimitiveResponse { ... } fn json_objkeys<K, P, R, RR>( self, key: K, path: P ) -> PreparedCommand<'a, Self, RR> where Self: Sized, K: SingleArg, P: SingleArg, R: PrimitiveResponse + DeserializeOwned, RR: CollectionResponse<Vec<R>> { ... } fn json_objlen<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_resp<K, P, VV>( self, key: K, path: P ) -> PreparedCommand<'a, Self, VV> where Self: Sized, K: SingleArg, P: SingleArg, VV: CollectionResponse<Value> { ... } fn json_set<K, P, V>( self, key: K, path: P, value: V, condition: SetCondition ) -> PreparedCommand<'a, Self, ()> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg { ... } fn json_strappend<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_strlen<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_toggle<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R> where Self: Sized, K: SingleArg, P: SingleArg, R: CollectionResponse<Option<usize>> { ... } fn json_type<K, P, R, RR>( self, key: K, path: P ) -> PreparedCommand<'a, Self, RR> where Self: Sized, K: SingleArg, P: SingleArg, R: PrimitiveResponse + DeserializeOwned, RR: CollectionResponse<R> { ... }
}
Available on crate feature redis-json only.
Expand description

A group of Redis commands related to RedisJson

§See Also

RedisJson Commands

Provided Methods§

source

fn json_arrappend<K, P, V, VV, R>( self, key: K, path: P, values: VV ) -> PreparedCommand<'a, Self, R>

Append the json values into the array at path after the last element in it

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • values - one or more values to append to one or more arrays.
§Return

A collection of integer replies for each path, the array’s new size, or nil, if the matching JSON value is not an array.

§See Also

https://redis.io/commands/json.arrappend/

source

fn json_arrindex<K, P, V, R>( self, key: K, path: P, value: V, options: JsonArrIndexOptions ) -> PreparedCommand<'a, Self, R>

Search for the first occurrence of a scalar JSON value in an array

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
  • value - value index to find in one or more arrays.
§Return

A collection of integer replies for each path,

the first position in the array of each JSON value that matches the path, -1 if unfound in the array, or nil, if the matching JSON value is not an array.

§See Also

https://redis.io/commands/json.arrindex/

source

fn json_arrinsert<K, P, V, VV, R>( self, key: K, path: P, index: isize, values: VV ) -> PreparedCommand<'a, Self, R>

Insert the json values into the array at path before the index (shifts to the right)

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • index- The position in the array where you want to insert a value. 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 - one or more values to insert in one or more arrays.
§Return

A collection of integer replies for each path, the array’s new size, or nil, if the matching JSON value is not an array.

§See Also

https://redis.io/commands/json.arrinsert/

source

fn json_arrlen<K, P, R>(self, key: K, path: P) -> PreparedCommand<'a, Self, R>

Report the length of the JSON array at path in key

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

A collection of integer replies, an integer for each matching value, each is the array’s length, or nil, if the matching value is not an array.

§See Also

https://redis.io/commands/json.arrlen/

source

fn json_arrpop<K, P, R, RR>( self, key: K, path: P, index: isize ) -> PreparedCommand<'a, Self, RR>

Remove and return an element from the index in the array

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • index- is position in the array to start popping from. Default is -1, meaning the last element. Out-of-range indexes round to their respective array ends. Popping an empty array returns null.
§Return

A collection of bulk string replies for each path, each reply is the popped JSON value, or nil, if the matching JSON value is not an array.

§See Also

https://redis.io/commands/json.arrpop/

source

fn json_arrtrim<K, P, R>( self, key: K, path: P, start: isize, stop: isize ) -> PreparedCommand<'a, Self, R>

Remove and return an element from the index in the array

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • start- The index of the first element to keep (previous elements are trimmed).
  • stop - the index of the last element to keep (following elements are trimmed), including the last element. Negative values are interpreted as starting from the end.
§Return

A collection of integer replies for each path, the array’s new size, or nil, if the matching JSON value is not an array.

§See Also

https://redis.io/commands/json.arrtrim/

source

fn json_clear<K, P>(self, key: K, path: P) -> PreparedCommand<'a, Self, usize>
where Self: Sized, K: SingleArg, P: SingleArg,

Clear container values (arrays/objects) and set numeric values to 0

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
§Return

The number of values cleared.

§See Also

https://redis.io/commands/json.clear/

source

fn json_debug_memory<K, P, R>( self, key: K, path: P ) -> PreparedCommand<'a, Self, R>

Report a value’s memory usage in bytes

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
§Return

A collection of integer replies for each path, the value size in bytes

§See Also

https://redis.io/commands/json.debug-memory/

source

fn json_del<K, P>(self, key: K, path: P) -> PreparedCommand<'a, Self, usize>
where Self: Sized, K: SingleArg, P: SingleArg,

Delete a value

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
§Return

The number of paths deleted (0 or more).

§See Also

https://redis.io/commands/json.del/

source

fn json_forget<K, P>(self, key: K, path: P) -> PreparedCommand<'a, Self, usize>
where Self: Sized, K: SingleArg, P: SingleArg,

See json_del

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
§Return

The number of paths deleted (0 or more).

§See Also

https://redis.io/commands/json.forget/

source

fn json_get<K, V>( self, key: K, options: JsonGetOptions ) -> PreparedCommand<'a, Self, V>
where Self: Sized, K: SingleArg, V: PrimitiveResponse,

Return the value at path in JSON serialized form

§Arguments
§Return

A collection of bulk string replies. Each string is the JSON serialization of each JSON value that matches a path

§See Also

https://redis.io/commands/json.get/

source

fn json_mget<K, KK, P, V, VV>( self, keys: KK, path: P ) -> PreparedCommand<'a, Self, VV>

Return the values at path from multiple key arguments

§Arguments
§Return

A collection of bulk string replies specified as the JSON serialization of the value at each key’s path.

§See Also

https://redis.io/commands/json.mget/

source

fn json_numincrby<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R>
where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: PrimitiveResponse,

Increment the number value stored at path by number

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • value - number value to increment.
§Return

A bulk string reply specified as a stringified new value for each path, or nil, if the matching JSON value is not a number.

§See Also

https://redis.io/commands/json.numincrby/

source

fn json_nummultby<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R>
where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg, R: PrimitiveResponse,

Multiply the number value stored at path by number

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • value - number value to increment.
§Return

A bulk string reply specified as a stringified new value for each path, or nil, if the matching JSON value is not a number.

§See Also

https://redis.io/commands/json.nummultby/

source

fn json_objkeys<K, P, R, RR>( self, key: K, path: P ) -> PreparedCommand<'a, Self, RR>

Return the keys in the object that’s referenced by path

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

A collection of collection replies for each path, a collection of the key names in the object as a bulk string reply, or an empty collection if the matching JSON value is not an object.

§See Also

https://redis.io/commands/json.objkeys/

source

fn json_objlen<K, P, R>(self, key: K, path: P) -> PreparedCommand<'a, Self, R>

Report the number of keys in the JSON object at path in key

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

A collection of integer replies for each path specified as the number of keys in the object or nil, if the matching JSON value is not an object.

§See Also

https://redis.io/commands/json.objlen/

source

fn json_resp<K, P, VV>(self, key: K, path: P) -> PreparedCommand<'a, Self, VV>
where Self: Sized, K: SingleArg, P: SingleArg, VV: CollectionResponse<Value>,

Return the JSON in key in Redis serialization protocol specification form

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

A collection of Values

This command uses the following mapping from JSON to RESP:

  • JSON null maps to the bulk string reply.
  • JSON false and true values map to the simple string reply.
  • JSON number maps to the integer reply or bulk string reply, depending on type.
  • JSON string maps to the bulk string reply.
  • JSON array is represented as an array reply in which the first element is the simple string reply [, followed by the array’s elements.
  • JSON object is represented as an array reply in which the first element is the simple string reply {. Each successive entry represents a key-value pair as a two-entry array reply of the bulk string reply.
§See Also

https://redis.io/commands/json.resp/

source

fn json_set<K, P, V>( self, key: K, path: P, value: V, condition: SetCondition ) -> PreparedCommand<'a, Self, ()>
where Self: Sized, K: SingleArg, P: SingleArg, V: SingleArg,

Set the JSON value at path in key

§Arguments
  • key - The key to modify.
  • path - JSONPath to specify.
    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.
  • value- The value to set at the specified path
  • condition- See SetCondition
§See Also

https://redis.io/commands/json.set/

source

fn json_strappend<K, P, V, R>( self, key: K, path: P, value: V ) -> PreparedCommand<'a, Self, R>

Append the json-string values to the string at path

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
  • value - number value to increment.
§Return

A collection of integer replies for each path, the string’s new length, or nil, if the matching JSON value is not a string.

§See Also

https://redis.io/commands/json.strappend/

source

fn json_strlen<K, P, R>(self, key: K, path: P) -> PreparedCommand<'a, Self, R>

Report the length of the JSON String at path in key

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

returns by recursive descent a collection of integer replies for each path, the array’s length, or nil, if the matching JSON value is not a string.

§See Also

https://redis.io/commands/json.strlen/

source

fn json_toggle<K, P, R>(self, key: K, path: P) -> PreparedCommand<'a, Self, R>

Toggle a Boolean value stored at path

§Arguments
  • key - The key to modify.
  • path- The JSONPath to specify.
§Return

A collection of integer replies for each path, the new value (0 if false or 1 if true), or nil for JSON values matching the path that are not Boolean.

§See Also

https://redis.io/commands/json.toggle/

source

fn json_type<K, P, R, RR>( self, key: K, path: P ) -> PreparedCommand<'a, Self, RR>

Report the type of JSON value at path

§Arguments
  • key - The key to parse.
  • path- The JSONPath to specify.
§Return

A collection of string replies for each path, specified as the value’s type.

§See Also

https://redis.io/commands/json.type/

Implementors§

source§

impl<'a> JsonCommands<'a> for &'a Client

source§

impl<'a> JsonCommands<'a> for &'a mut Transaction

source§

impl<'a, 'b> JsonCommands<'a> for &'a mut Pipeline<'b>