36 releases
0.13.3 | May 25, 2024 |
---|---|
0.13.1 | Apr 21, 2024 |
0.12.9 | Mar 12, 2024 |
0.12.8 | Dec 29, 2023 |
0.7.1 | Dec 30, 2022 |
#50 in Database interfaces
8,061 downloads per month
Used in 4 crates
1.5MB
36K
SLoC
An asynchronous Redis client for Rust.
Documentation
Philosophy
- Low allocations
- Full async library
- Lock free implementation
- Rust idiomatic API
- Multiplexing as a core feature
Features
- Full documentation with multiple examples
- Support all Redis Commands until Redis 7.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)
- Redis Stack support:
- RedisJSON v2.4 support
- RedisSearch v2.6 support
- RedisGraph v2.10 support
- RedisBloom v2.4 support
- RedisTimeSeries v1.8 support
Basic Usage
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(())
}
Tests
- From the
redis
directory, rundocker_up.sh
ordocker_up.cmd
- run
cargo test --features pool,redis-stack,tokio-tls
(Tokio runtime) - run
cargo test --no-default-features --features redis-stack,async-std-runtime,async-std-tls
(async-std runtime)
Benchmarks
- From the
redis
directory, rundocker_up.sh
ordocker_up.cmd
- run
cargo bench
Dependencies
~6–18MB
~246K SLoC