redis-rs
An idiomatic, high-level Redis and Valkey client for Rust with sync, async, and cluster support.
Repository Health
Technical Analysis
redis-rs is a Rust library implementing a high-level client for Redis, Valkey, and any other RESP (Redis Serialization Protocol) compliant server. It exposes the full range of Redis functionality through a flexible, low-level command API paired with a customizable type-conversion trait, so commands can return results directly as the Rust type the caller expects rather than requiring manual parsing of raw replies.
The crate supports both synchronous and asynchronous (tokio/async-std) connections, connection pooling via r2d2/bb8, pub/sub, Redis Cluster and Sentinel topologies, TLS, and pipelining. It’s one of the most widely depended-upon Redis clients in the Rust ecosystem, published as the redis crate and consumed transitively by countless web services, caching layers, and job queues built in Rust.
What You Get
- Synchronous and async (tokio, async-std) client connections to Redis/Valkey
- A generic command API with a
FromRedisValue/ToRedisArgstype-conversion system - Redis Cluster and Sentinel client support for high-availability deployments
- Pub/sub support including an async subscription tracker
- Pipelining and transaction (MULTI/EXEC) support
- Optional integration with
r2d2andbb8connection pools, plus TLS and cloud-auth (Entra ID) support
Common Use Cases
- Caching layers for Rust web services (session storage, response caching, rate limiting)
- Pub/sub messaging and event distribution between Rust services
- Connecting to Redis Cluster or Sentinel deployments for high-availability production setups
- Job/task queues backed by Redis lists or streams
- Async data access in tokio-based Rust backends via the async connection API
Under The Hood
Architecture - The workspace root Cargo.toml defines a multi-crate layout with the primary redis crate under redis/, plus redis-test for test utilities and a valkey/ directory tracking Valkey-specific compatibility. Inside redis/src/, the client is split by concern: connection.rs and client.rs handle connection establishment, cmd.rs/pipeline.rs build and dispatch commands, parser.rs decodes RESP replies, types.rs defines the FromRedisValue/ToRedisArgs conversion traits, and dedicated modules (cluster_handling/, sentinel.rs, subscription_tracker.rs, aio/) layer cluster, sentinel, and async pub/sub support on top of the core connection primitives.
Tech Stack - Pure Rust, edition 2024, minimum Rust version 1.88 per redis/Cargo.toml. Core dependencies are intentionally minimal (ryu, itoa, percent-encoding for formatting/parsing), with heavier functionality — tokio/async-std runtimes, TLS backends, r2d2/bb8 pooling, and cluster support — gated behind Cargo feature flags so consumers only pay for what they use. An afl/ directory holds fuzz-testing harnesses for the RESP parser.
Code Quality - The redis/tests/ directory contains 27 integration test files covering cluster handling, TLS, pub/sub, scripting, and pooling integrations (r2d2.rs, bb8.rs), and a CODING_CONVENTIONS.md documents the project’s style expectations for contributors. Fuzz testing via afl on the parser indicates attention to protocol-parsing correctness, which matters given RESP is a binary-safe, hand-rolled protocol. CI runs via GitHub Actions with a badge showing build status against multiple Redis/Valkey versions.
API Design - The API centers on a Client/Connection pair and a cmd() builder for issuing arbitrary Redis commands, with results generically deserialized via the FromRedisValue trait — so .query::<String>() or .query::<HashMap<String, i32>>() both work against the same command without separate typed methods per command. This low-level-but-typed approach trades some discoverability (commands aren’t individually named methods for every Redis command) for flexibility across the full RESP command surface, including newer Redis/Valkey commands the crate hasn’t added a dedicated wrapper for yet.
Used by 13 apps in this directory
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.
Svix
Automation · Developer Tools
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.
Trieve
AI Development · Developer Tools · Search
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.