Struct r2d2_redis::RedisConnectionManager [] [src]

pub struct RedisConnectionManager {
    // some fields omitted
}

An r2d2::ConnectionManager for redis::Clients.

Example

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

use std::default::Default;
use std::ops::Deref;
use std::thread;

use r2d2_redis::RedisConnectionManager;

fn main() {
    let config = Default::default();
    let manager = RedisConnectionManager::new("redis://localhost").unwrap();
    let pool = 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();
    }
}

Methods

impl RedisConnectionManager

fn new<T: IntoConnectionInfo>(params: T) -> Result<RedisConnectionManager, RedisError>

Creates a new RedisConnectionManager.

See redis::Client::open for a description of the parameter types.

Trait Implementations

impl ManageConnection for RedisConnectionManager

type Connection = Connection

type Error = Error

fn connect(&self) -> Result<Connection, Error>

fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>

fn has_broken(&self, _conn: &mut Connection) -> bool

Derived Implementations

impl Debug for RedisConnectionManager

fn fmt(&self, __arg_0: &mut Formatter) -> Result