Installation
[dependencies]
iris_client = "0.1.1"
Example
use iris_client::{connect, Expression, DeleteExpression};
#[tokio::main]
async fn main() -> Result<(), String> {
let mut client = connect("127.0.0.1:3000").await?;
let user_id = client.set("user:joe", "foo bar").await?;
let user_value = client.get(user_id).await?;
let list_count = client.list(Expression::Number(-1)).await?;
let list_expr = client.list(Expression::Range(0..3)).await?;
let count = client.count(Expression::Number(-1)).await?;
let deleted_user_id = client.delete(DeleteExpression::ID("user:joe")).await?;
let deleted_user_count = client.delete(DeleteExpression::Number(2)).await?;
let deleted_user_expr = client.delete(DeleteExpression::Range(0..2)).await?;
let raw = client.delete("GET user:joe").await?;
Ok(())
}
Pipes
You also can pipe commands. The return value of the previous command will be appended to the current command
use iris_client::connect;
#[tokio::main]
async fn main() -> Result<(), String> {
let mut client = connect("127.0.0.1:3000").await?;
let pipe_commands = client.pipe()
.pipe()
.set("someid", "foo bar") .get("") .await?;
let pipe_raw = client.raw("SET someid this is data ~> GET").await?;
Ok(())
}
Contribution
Contributions to iris are welcome! If you have ideas for improvements, new features, or bug fixes, feel free to open an issue or submit a pull request on iris