2 releases
0.0.0-alpha2 | Dec 4, 2024 |
---|---|
0.0.0-alpha1 | Nov 26, 2024 |
#492 in Hardware support
274 downloads per month
Used in bb8-valkey
5KB
71 lines
valkey-rs
A Valkey driver for Rust.
This project will include sync, async, and pooling. It is still a work-in-progress.
Usage
Synchronous:
use std::net::{Ipv6Addr, SocketAddr};
use valkey::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::from((Ipv6Addr::LOCALHOST, 6379));
let mut client = Client::connect(addr)?;
client.set("hello", "world")?;
let value = client.get("hello")?.unwrap();
println!("Hello {value}");
Ok(())
}
Async:
use std::net::{Ipv6Addr, SocketAddr};
use tokio_valkey::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::from((Ipv6Addr::LOCALHOST, 6379));
let mut client = Client::connect(addr).await?;
client.set("hello", "world").await?;
let value = client.get("hello").await?.unwrap();
println!("Hello {value}");
Ok(())
}
Crates
Use valkey for sync and tokio-valkey for async.
Dependencies
~2–10MB
~97K SLoC