Docs

Rust

redis-rs with Tokio and rustls.

Each example reads the connection URL from VALKEY_URL; copy it from your instance page in the dashboard. See connection details and limits for what applies to every client.

redis-rs

Enable a TLS feature of the redis crate; with it, rediss:// URLs connect over TLS.

Install
cargo add redis --features tokio-comp,tokio-rustls-compcargo add tokio --features full
src/main.rs
use redis::AsyncCommands; #[tokio::main]async fn main() -> redis::RedisResult<()> {    let url = std::env::var("VALKEY_URL").expect("VALKEY_URL is not set");    let client = redis::Client::open(url)?;    let mut con = client.get_multiplexed_async_connection().await?;     let _: () = con.set_ex("greeting", "hello", 60).await?;    let greeting: String = con.get("greeting").await?;    println!("{greeting}");    Ok(())}

© 2026 KVNest · Managed Redis and Valkey, hosted in the EU

Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. KVNest is not affiliated with or endorsed by Redis Ltd.