Crates.io | redis_cluster_rs2 |
lib.rs | redis_cluster_rs2 |
version | 0.23.3 |
source | src |
created_at | 2024-01-28 01:07:53.124319 |
updated_at | 2024-01-28 01:07:53.124319 |
description | Redis cluster driver for Rust. |
homepage | https://github.com/chunhui2001/redis_cluster_rs |
repository | https://github.com/chunhui2001/redis_cluster_rs |
max_upload_size | |
id | 1117208 |
size | 30,146 |
This is a Rust implementation for Redis cluster library.
Documentation is available at here.
This library extends redis-rs library to be able to use cluster. Client impletemts traits of ConnectionLike and Commands. So you can use redis-rs's access methods. If you want more information, read document of redis-rs.
Note that this library is currently not have features of Pubsub.
extern crate redis_cluster_rs;
use redis_cluster_rs::{Client, Commands};
fn main() {
let nodes = vec!["redis://127.0.0.1:6379/", "redis://127.0.0.1:6378/", "redis://127.0.0.1:6377/"];
let client = Client::open(nodes).unwrap();
let mut connection = client.get_connection().unwrap();
let _: () = connection.set("test", "test_data").unwrap();
let res: String = connection.get("test").unwrap();
assert_eq!(res, "test_data");
}
extern crate redis_cluster_rs;
use redis_cluster_rs::{Client, 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 client = Client::open(nodes).unwrap();
let mut connection = client.get_connection().unwrap();
let key = "test";
let _: () = pipe()
.rpush(key, "123").ignore()
.ltrim(key, -10, -1).ignore()
.expire(key, 60).ignore()
.query(&mut connection).unwrap();
}