21 releases (5 stable)

Uses new Rust 2024

new 1.0.4 May 29, 2026
1.0.2 Feb 27, 2026
1.0.1 Dec 25, 2025
0.13.0 Oct 6, 2025
0.1.1 Oct 18, 2022

#1800 in Database interfaces

Download history 30211/week @ 2026-02-09 30490/week @ 2026-02-16 26335/week @ 2026-02-23 40633/week @ 2026-03-02 33090/week @ 2026-03-09 20720/week @ 2026-03-16 23161/week @ 2026-03-23 23321/week @ 2026-03-30 20522/week @ 2026-04-06 16952/week @ 2026-04-13 16740/week @ 2026-04-20 16261/week @ 2026-04-27 16137/week @ 2026-05-04 17647/week @ 2026-05-11 16122/week @ 2026-05-18 14291/week @ 2026-05-25

64,791 downloads per month
Used in 7 crates

BSD-3-Clause

1.5MB
27K SLoC

Testing support

This crate provides utilities for testing Redis clients and applications:

  • Mock Connections: MockRedisConnection implements ConnectionLike and can be used in the same place as any other type that behaves like a Redis connection. This is useful for writing unit tests without needing a real Redis server.
  • Standalone Servers: server::RedisServer provides an easy way to spin up and manage a real local Redis instance for integration tests.
  • Clusters: cluster::RedisCluster provides functionality to spawn and configure a local Redis cluster with multiple nodes and replicas.
  • Sentinels: sentinel::RedisSentinelCluster provides functionality to spawn and configure a local Redis sentinel cluster.

Example (Mock Connection)

use redis::{ConnectionLike, RedisError};
use redis_test::{MockCmd, MockRedisConnection};

fn my_exists<C: ConnectionLike>(conn: &mut C, key: &str) -> Result<bool, RedisError> {
    let exists: bool = redis::cmd("EXISTS").arg(key).query(conn)?;
    Ok(exists)
}

let mut mock_connection = MockRedisConnection::new(vec![
    MockCmd::new(redis::cmd("EXISTS").arg("foo"), Ok("1")),
]);

let result = my_exists(&mut mock_connection, "foo").unwrap();
assert_eq!(result, true);

redis-test

Testing utilities for the redis-rs crate.

Dependencies

~5–12MB
~243K SLoC