Crates.io | redis_cluster_async |
lib.rs | redis_cluster_async |
version | 0.8.1 |
source | src |
created_at | 2019-11-15 14:07:20.751836 |
updated_at | 2023-08-10 14:20:07.021853 |
description | Async redis cluster driver for Rust. |
homepage | https://github.com/redis-rs/redis-cluster-async |
repository | https://github.com/redis-rs/redis-cluster-async |
max_upload_size | |
id | 181512 |
size | 74,517 |
The functionality of this crate has been merged into the main redis-rs project.
A Rust crate implementing a Redis cluster client.
Documentation is available at here.
This library builds upon the redis-rs crate to enable working with a Redis cluster (instead of single Redis nodes).
extern crate futures;
extern crate tokio;
use futures::prelude::*;
use redis_cluster_async::{Client, redis::cmd};
fn main() {
let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
let mut runtime = tokio::runtime::Runtime::new().unwrap();
let client = Client::open(nodes).unwrap();
let (_, res): (_, String) = runtime.block_on(client.get_connection()
.and_then(|connection| {
cmd("SET").arg("test").arg("test_data").clone()
.query_async(connection)
.and_then(|(connection, ())|
cmd("GET").arg("test")
.query_async(connection)
)
})
)
.unwrap();
assert_eq!(res, "test_data");
}
extern crate futures;
extern crate tokio;
use futures::prelude::*;
use redis_cluster_async::{Client, redis::{PipelineCommands, pipe}};
fn main() {
let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
let mut runtime = tokio::runtime::Runtime::new().unwrap();
let client = Client::open(nodes).unwrap();
let _: (_, ()) = runtime.block_on(
client.get_connection().and_then(|connection| {
let key = "test";
pipe()
.rpush(key, "123").ignore()
.ltrim(key, -10, -1).ignore()
.expire(key, 60).ignore()
.query_async(connection)
}))
.unwrap();
}
This project is built upon the synchronous redis cluster implementation in https://github.com/atuk721/redis-cluster-rs .