r2d2_redis 0.1.0

Redis support for the r2d2 connection pool
docs.rs failed to build r2d2_redis-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: r2d2_redis-0.14.0

r2d2-redis

Build Status

redis-rs support library for the r2d2 connection pool totally based on Steven Fackler's r2d2-postgres. All props to him.

Documentation is available at https://nevdelap.github.io/r2d2-redis/doc/r2d2_redis

Example

extern crate r2d2;
extern crate r2d2_redis;
extern crate redis;

use std::default::Default;
use std::ops::Deref;
use std::sync::Arc;
use std::thread;
use r2d2_redis::RedisConnectionManager;

fn main() {
    let config = Default::default();
    let manager = RedisConnectionManager::new("redis://localhost").unwrap();
    let pool = Arc::new(r2d2::Pool::new(config, manager).unwrap());

    let mut handles = vec![];

    for _i in 0..10i32 {
        let pool = pool.clone();
        handles.push(thread::spawn(move || {
            let conn = pool.get().unwrap();
            let reply = redis::cmd("PING").query::<String>(conn.deref()).unwrap();
            assert_eq!("PONG", reply);
        }));
    }

    for h in handles {
        h.join().unwrap();
    }
}