#synchronous #driver #sync

valkey

An ergonomic, synchronous Valkey driver

5 releases

0.0.0-alpha5 Dec 6, 2024
0.0.0-alpha4 Dec 4, 2024
0.0.0-alpha1 Nov 26, 2024

#320 in Hardware support

Download history 121/week @ 2024-11-23 353/week @ 2024-11-30 96/week @ 2024-12-07 2/week @ 2024-12-14

197 downloads per month

MIT license

7KB
137 lines

valkey-rs

Crates.io docs

A Valkey driver for Rust.

Compatibility with other key-value stores is not guaranteed.

This project will include sync, async, and pooling. It is currently incomplete and 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

~305–415KB