Trait fred::interfaces::RedisJsonInterface
source · pub trait RedisJsonInterface: ClientLike + Sized {
Show 22 methods
// Provided methods
fn json_arrappend<R, K, P, V>(
&self,
key: K,
path: P,
values: Vec<V>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_arrindex<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
start: Option<i64>,
stop: Option<i64>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_arrinsert<R, K, P, V>(
&self,
key: K,
path: P,
index: i64,
values: Vec<V>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_arrlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_arrpop<R, K, P>(
&self,
key: K,
path: Option<P>,
index: Option<i64>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_arrtrim<R, K, P>(
&self,
key: K,
path: P,
start: i64,
stop: i64,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_clear<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_debug_memory<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_del<R, K, P>(
&self,
key: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_get<R, K, I, N, S, P>(
&self,
key: K,
indent: Option<I>,
newline: Option<N>,
space: Option<S>,
paths: P,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
I: Into<Str>,
N: Into<Str>,
S: Into<Str>,
P: Into<MultipleStrings> { ... }
fn json_merge<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_mget<R, K, P>(
&self,
keys: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<MultipleKeys>,
P: Into<Str> { ... }
fn json_mset<R, K, P, V>(
&self,
values: Vec<(K, P, V)>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_numincrby<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_objkeys<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_objlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_resp<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_set<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
options: Option<SetOptions>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_strappend<R, K, P, V>(
&self,
key: K,
path: Option<P>,
value: V,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str>,
V: Into<Value> { ... }
fn json_strlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_toggle<R, K, P>(
&self,
key: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
fn json_type<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
where R: FromRedis,
K: Into<RedisKey>,
P: Into<Str> { ... }
}i-redis-json only.Expand description
The client commands in the RedisJSON interface.
§String Values
This interface uses serde_json::Value as the baseline type and will convert non-string values to RESP bulk strings via to_string.
Some of the RedisJSON commands include the following notice in the documentation:
To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example: ‘“silver”’.
The serde_json::to_string functions are often the easiest way to do this. The json_quote macro can also help.
For example:
use fred::{json_quote, prelude::*};
use serde_json::json;
async fn example(client: &RedisClient) -> Result<(), RedisError> {
let _: () = client.json_set("foo", "$", json!(["a", "b"]), None).await?;
// need to double quote string values in this context
let size: i64 = client
.json_arrappend("foo", Some("$"), vec![
json!("c").to_string(),
// or
serde_json::to_string(&json!("d"))?,
// or
json_quote!("e"),
])
.await?;
assert_eq!(size, 5);
Ok(())
}Provided Methods§
sourcefn json_arrappend<R, K, P, V>(
&self,
key: K,
path: P,
values: Vec<V>,
) -> impl Future<Output = RedisResult<R>>
fn json_arrappend<R, K, P, V>( &self, key: K, path: P, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>>
Append the json values into the array at path after the last element in it.
sourcefn json_arrindex<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
start: Option<i64>,
stop: Option<i64>,
) -> impl Future<Output = RedisResult<R>>
fn json_arrindex<R, K, P, V>( &self, key: K, path: P, value: V, start: Option<i64>, stop: Option<i64>, ) -> impl Future<Output = RedisResult<R>>
Search for the first occurrence of a JSON value in an array.
sourcefn json_arrinsert<R, K, P, V>(
&self,
key: K,
path: P,
index: i64,
values: Vec<V>,
) -> impl Future<Output = RedisResult<R>>
fn json_arrinsert<R, K, P, V>( &self, key: K, path: P, index: i64, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>>
Insert the json values into the array at path before the index (shifts to the right).
sourcefn json_arrlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_arrlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Report the length of the JSON array at path in key.
sourcefn json_arrpop<R, K, P>(
&self,
key: K,
path: Option<P>,
index: Option<i64>,
) -> impl Future<Output = RedisResult<R>>
fn json_arrpop<R, K, P>( &self, key: K, path: Option<P>, index: Option<i64>, ) -> impl Future<Output = RedisResult<R>>
Remove and return an element from the index in the array
sourcefn json_arrtrim<R, K, P>(
&self,
key: K,
path: P,
start: i64,
stop: i64,
) -> impl Future<Output = RedisResult<R>>
fn json_arrtrim<R, K, P>( &self, key: K, path: P, start: i64, stop: i64, ) -> impl Future<Output = RedisResult<R>>
Trim an array so that it contains only the specified inclusive range of elements
sourcefn json_clear<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_clear<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Clear container values (arrays/objects) and set numeric values to 0
sourcefn json_debug_memory<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_debug_memory<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Report a value’s memory usage in bytes
sourcefn json_del<R, K, P>(
&self,
key: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
fn json_del<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>>
Delete a value.
sourcefn json_get<R, K, I, N, S, P>(
&self,
key: K,
indent: Option<I>,
newline: Option<N>,
space: Option<S>,
paths: P,
) -> impl Future<Output = RedisResult<R>>
fn json_get<R, K, I, N, S, P>( &self, key: K, indent: Option<I>, newline: Option<N>, space: Option<S>, paths: P, ) -> impl Future<Output = RedisResult<R>>
Return the value at path in JSON serialized form.
sourcefn json_merge<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
) -> impl Future<Output = RedisResult<R>>
fn json_merge<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>>
Merge a given JSON value into matching paths.
sourcefn json_mget<R, K, P>(
&self,
keys: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
fn json_mget<R, K, P>( &self, keys: K, path: P, ) -> impl Future<Output = RedisResult<R>>
Return the values at path from multiple key arguments.
sourcefn json_mset<R, K, P, V>(
&self,
values: Vec<(K, P, V)>,
) -> impl Future<Output = RedisResult<R>>
fn json_mset<R, K, P, V>( &self, values: Vec<(K, P, V)>, ) -> impl Future<Output = RedisResult<R>>
Set or update one or more JSON values according to the specified key-path-value triplets.
sourcefn json_numincrby<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
) -> impl Future<Output = RedisResult<R>>
fn json_numincrby<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>>
Increment the number value stored at path by number
sourcefn json_objkeys<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_objkeys<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Return the keys in the object that’s referenced by path.
sourcefn json_objlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_objlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Report the number of keys in the JSON object at path in key.
sourcefn json_resp<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_resp<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Return the JSON in key in Redis serialization protocol specification form.
sourcefn json_set<R, K, P, V>(
&self,
key: K,
path: P,
value: V,
options: Option<SetOptions>,
) -> impl Future<Output = RedisResult<R>>
fn json_set<R, K, P, V>( &self, key: K, path: P, value: V, options: Option<SetOptions>, ) -> impl Future<Output = RedisResult<R>>
Set the JSON value at path in key.
sourcefn json_strappend<R, K, P, V>(
&self,
key: K,
path: Option<P>,
value: V,
) -> impl Future<Output = RedisResult<R>>
fn json_strappend<R, K, P, V>( &self, key: K, path: Option<P>, value: V, ) -> impl Future<Output = RedisResult<R>>
Append the json-string values to the string at path.
sourcefn json_strlen<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_strlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Report the length of the JSON String at path in key.
sourcefn json_toggle<R, K, P>(
&self,
key: K,
path: P,
) -> impl Future<Output = RedisResult<R>>
fn json_toggle<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>>
Toggle a Boolean value stored at path.
sourcefn json_type<R, K, P>(
&self,
key: K,
path: Option<P>,
) -> impl Future<Output = RedisResult<R>>
fn json_type<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
Report the type of JSON value at path.