A lightweight Redis-compatible implementation powered by Tokio. It supports PING, GET, and SET (with EX/PX expiration) and ships with async, blocking, and buffered clients as well as CLI and server binaries. The project is intended for learning how to build RESP-based systems in async Rust; do not use it in production.
- RESP encoding/decoding via the
frameandparsemodules plus aConnectionabstraction that keeps network IO pipeline-friendly. - In-memory database
Dbwith optional TTL, a background cleanup task, and graceful shutdown hooks. - Command layer covering
PING,GET,SET, with anUnknownfallback for unsupported commands. - Server binary
simple-redis-serverthat enforces a connection cap, handles concurrent clients, and supports graceful shutdown. - Client options:
clients::Client: async API offeringget/set/set_expires/ping.clients::BlockingClient: synchronous wrapper around the async client.clients::BufferedClient: request serialization via an internal channel for multi-task scenarios.simple-redis-cli: Clap-powered CLI for issuing commands easily.
- Rust 1.72+ (Tokio 1.x line)
cargobuild tool
cargo run --bin simple-redis-server -- --host 127.0.0.1 --port 6379# Ping
cargo run --bin simple-redis-cli -- ping
# Set + Get
cargo run --bin simple-redis-cli -- set my-key my-value --expires 5000
cargo run --bin simple-redis-cli -- get my-keyuse bytes::Bytes;
use simple_redis_with_rust::connect;
#[tokio::main]
async fn main() -> simple_redis_with_rust::Result<()> {
let mut client = connect("127.0.0.1:6379").await?;
client.set("hello", Bytes::from("world")).await?;
println!("{:?}", client.get("hello").await?);
Ok(())
}Run cargo test (unit + integration) to validate the core modules. When adding features or commands, extend the suites for frame, parse, db, and cmd to cover new behavior.