An asynchronous Redis client for Rust.
Crate docs.rs Build License libs.tech recommends
- Low allocations
- Full async library
- Lock free implementation
- Rust idiomatic API
- Multiplexing as a core feature
- Full documentation with multiple examples
- Support all Redis Commands until Redis 8.0
- Async support (tokio or async-std)
- Different client modes:
- Single client
- Multiplexed client
- Pooled client manager (based on bb8)
- Automatic command batching
- Advanced reconnection & retry strategy
- Pipelining support
- Configuration with Redis URL or dedicated builder
- TLS support
- Transaction support
- Pub/sub support
- Sentinel support
- LUA Scripts/Functions support
- Cluster support (minimus supported Redis version is 6)
- Client-side caching support
- RedisGraph v2.10 support
Rustis uses the RESP3 protocol exclusively.
The HELLO 3 command is automatically sent when establishing a connection.
Therefore, your Redis server must support RESP3 (Redis ≥6.0+ with RESP3 enabled).
If you use Redis 5 or older, or your Redis 6+ server still defaults to RESP2,
Rustis will not work.
To verify your server supports RESP3:
redis-cli --raw HELLO 3
If you see server info (role, version, etc.), you're good to go. If you get an error, upgrade Redis.
use rustis::{ client::Client, commands::{FlushingMode, ServerCommands, StringCommands}, Result, }; #[tokio::main] async fn main() -> Result<()> { // Connect the client to a Redis server from its IP and port let client = Client::connect("127.0.0.1:6379").await?; // Flush all existing data in Redis client.flushdb(FlushingMode::Sync).await?; // sends the command SET to Redis. This command is defined in the StringCommands trait client.set("key", "value").await?; // sends the command GET to Redis. This command is defined in the StringCommands trait let value: String = client.get("key").await?; println!("value: {value:?}"); Ok(()) }
- From the
redisdirectory, rundocker_up.shordocker_up.cmd - run
cargo test --features pool,tokio-rustls,json,client-cache(Tokio runtime) - run
cargo test --no-default-features --features async-std-runtime,async-std-native-tls,json,client-cache(async-std runtime) - run
cargo fmt --all -- --check
- From the
redisdirectory, rundocker_up.shordocker_up.cmd - run
cargo bench